Advertisement
Guest User

Untitled

a guest
May 20th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. class LoginAction implements IAction
  2. {
  3. public function __construct ()
  4. {
  5.  
  6. }
  7.  
  8. private function exists($username, $password)
  9. {
  10. $connection = new mysqli('localhost', 'root', '', 'tema3');
  11. $query = "SELECT * from users";
  12.  
  13.  
  14. $result = $connection->query($query);
  15. $ok = 0;
  16. print_r($result);
  17. if ($result)
  18. {
  19. while ($row = $result->fetch_assoc() )
  20. {
  21. print_r($row);
  22. if (($row['password'] == md5($password)) && ($row['username'] == $username))
  23. {
  24. $ok = 1;
  25. break;
  26. }
  27. }
  28. }
  29. if ($ok == 1)
  30. {
  31. return true;
  32. }
  33. else
  34. {
  35. return false;
  36. }
  37. }
  38.  
  39.  
  40.  
  41. public function actionIsset ()
  42. {
  43. if (!isset($_POST))
  44. {
  45. return false;
  46. }
  47. $user = $_POST["username"];
  48. $pass = $_POST["password"];
  49.  
  50. if (empty($user) || empty($pass))
  51. {
  52. return false;
  53. }
  54.  
  55. return($this->exists($user, $password));
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement