Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once('connect.php');
- session_start();
- class Login {
- public $username;
- public $password;
- public $dbusername;
- public $dbpassword;
- public $take_num_rows;
- function __construct() {
- $this->username = $_POST['username'];
- $this->password = md5($_POST['password']);
- $take = "SELECT username,password FROM accounts WHERE username='$this->username'";
- $run_take = mysql_query($take);
- $take_assoc = mysql_fetch_assoc($run_take);
- $this->take_num_rows = mysql_num_rows($run_take);
- $this->dbusername = $take_assoc['username'];
- $this->dbpassword = $take_assoc['password'];
- }
- public function LoginUser() {
- if ($this->take_num_rows==0) {
- die ("Username not found!");
- } else if ($this->password!=$this->dbpassword) {
- die ("Incorrect Password!");
- } else {
- $_SESSION['username'] = $this->dbusername;
- echo "Successfully Logged in. <a href='index.php'>Return</a> to home.";
- }
- }
- }
- if (isset($_POST['login_submit'])) {
- $login = new Login();
- $login->LoginUser();
- }
- ?>
Add Comment
Please, Sign In to add comment