Guest User

Untitled

a guest
May 12th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <?php
  2. include_once('connect.php');
  3. session_start();
  4.  
  5. class Login {
  6.  
  7. public $username;
  8. public $password;
  9. public $dbusername;
  10. public $dbpassword;
  11. public $take_num_rows;
  12.  
  13. function __construct() {
  14. $this->username = $_POST['username'];
  15. $this->password = md5($_POST['password']);
  16.  
  17. $take = "SELECT username,password FROM accounts WHERE username='$this->username'";
  18. $run_take = mysql_query($take);
  19. $take_assoc = mysql_fetch_assoc($run_take);
  20. $this->take_num_rows = mysql_num_rows($run_take);
  21.  
  22. $this->dbusername = $take_assoc['username'];
  23. $this->dbpassword = $take_assoc['password'];
  24. }
  25.  
  26. public function LoginUser() {
  27.  
  28. if ($this->take_num_rows==0) {
  29. die ("Username not found!");
  30. } else if ($this->password!=$this->dbpassword) {
  31. die ("Incorrect Password!");
  32. } else {
  33. $_SESSION['username'] = $this->dbusername;
  34. echo "Successfully Logged in. <a href='index.php'>Return</a> to home.";
  35. }
  36.  
  37. }
  38. }
  39.  
  40. if (isset($_POST['login_submit'])) {
  41. $login = new Login();
  42. $login->LoginUser();
  43. }
  44.  
  45. ?>
Add Comment
Please, Sign In to add comment