Advertisement
Guest User

Untitled

a guest
May 20th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 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. while ($row = $result->fetch_assoc() )
  17. {
  18. print_r($row);
  19. if ($row['password'] == md5($password) && $row['username'] == $username)
  20. {
  21. $ok = 1;
  22. break;
  23. }
  24. }
  25. if ($ok == 1)
  26. {
  27. return true;
  28. }
  29. else
  30. {
  31. return false;
  32. }
  33. }
  34.  
  35.  
  36.  
  37. public function actionIsset ()
  38. {
  39. if (!isset($_POST))
  40. {
  41. return false;
  42. }
  43. $user = $_POST["username"];
  44. $pass = $_POST["password"];
  45.  
  46. if (empty($user) || empty($pass))
  47. {
  48. return false;
  49. }
  50.  
  51. return($this->exists($user, $password));
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement