Advertisement
Guest User

Untitled

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