Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Doc Comment Here
- */
- class User
- {
- /**
- * The database
- *
- * @var \PDO
- */
- protected $_db;
- /**
- * Create the database object
- *
- * @param array $config
- */
- public function __construct($config)
- {
- $dsn = 'mysql:host=' . $config['host'] . ';dbname=' . $config['dbname'];
- $this->_db = new \PDO($dsn, $config['user'], $config['pass']);
- }
- /**
- * Perform the login
- *
- * @param string $name The user name
- * @param string $pass The user password
- * @return
- */
- public function login($name, $pass)
- {
- if (!empty($name) && !empty($pass) ){
- $st = $this->db->prepare ("select * from users where where name=? and pass =? ");
- $st->bindValue(1, $name);
- $st->bindValue(2, $pass);
- $st->execute;
- if ($st->rowCount() == 1) {
- echo "Accesso Verificato";
- } else {
- echo "utente non riconosciuto";
- }
- } else {
- echo"Inserire Username e Password";
- }
- }
- }
- $config = parse_ini_file('/path/to/config.ini');
- $user = new User($config);
- $user->login($name, $pass);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement