Advertisement
Guest User

Untitled

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