Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // connect_mysql.php
- <?php
- define("DB_HOST", "localhost");
- define("DB_USER", "user");
- define("DB_PASS", "pass");
- define("DB_DB", "_notify");
- $dbc = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_DB);
- if (!$dbc) {
- die('Cannot connect to database: ' . $dbc->error);
- }
- ?>
- // index.php
- <?php
- include('./connect_mysql.php');
- class Login {
- public $user;
- private $pass;
- private $_authCode;
- public function __construct($user, $password) {
- $this->user = $user;
- $this->pass = $password;
- $this->_authCode = -1;
- }
- public function authCode() {
- return $this->_authCode;
- }
- public function authenticate() {
- $q = "SELECT username, password FROM users";
- $r = $dbc->query($q);
- while ($check = $r->fetch_object()) {
- if ($user == $check->username) {
- if (trim(md5('$password')) == $check->password) {
- $this->_authCode = 1;
- break;
- }
- else {
- $this->_authCode = 0;
- break;
- }
- }
- }
- }
- }
- ?>
Add Comment
Please, Sign In to add comment