Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. $email=$_POST['email'];
  3. $password=md5$_POST['password'];
  4.  
  5. $result = mysqli_query($con, "SELECT * FROM User WHERE email= '$email' AND password = '$password'");
  6. //var_dump($result);
  7.  
  8. $count = mysqli_num_rows($result);
  9. //var_dump($count);
  10.  
  11. if($count == 1)
  12. {
  13. echo ("Exists");
  14. }
  15. else
  16. {
  17. echo ("Error");
  18. }
  19.  
  20. ?>
  21.  
  22. $(document).ready(function() {
  23. $("#submit").click(function() {
  24.  
  25. var email = document.getElementById("email").value;
  26. var password = document.getElementById("password").value;
  27.  
  28. var xhttp = new XMLHttpRequest();
  29. xhttp.onreadystatechange = function()
  30. {
  31. if(this.readyState == 4 && this.status == 200)
  32. {
  33. var response = this.responseText;
  34.  
  35. if(response == "Exists")
  36. {
  37. window.location="content.html"
  38. }
  39.  
  40. else if(response == "Error")
  41. {
  42. alert("Wrong email or password");
  43. }
  44. }
  45. }
  46. xhttp.open("POST", "checkDetails.php", true);
  47. xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  48. xhttp.send("email="+email+"password="+password);
  49. return false;
  50. });
  51. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement