Advertisement
Guest User

login5

a guest
May 14th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. $username = $_POST['username'];
  2. $password = $_POST['password'];
  3.  
  4. $stmt = $conn->prepare("SELECT * FROM admin WHERE username = ?");
  5. $stmt->bind_param("s", $username);
  6. $stmt->execute();
  7. $result=$stmt->get_result();
  8.  
  9. if ($result->num_rows < 1) {
  10. ?>
  11. <script>
  12. alert('Cannot find account with the username');
  13. window.location='admin.php';
  14. </script>
  15. <?php
  16. } else {
  17. $row = $result->fetch_assoc();
  18. if (password_verify($password, $row['password'])) {
  19. $_SESSION['admin'] = $row['id'];
  20. ?>
  21. <script>
  22. alert('WELCOME ADMIN');
  23. window.location='admin/';
  24. </script>
  25. <?php
  26. } else {
  27. ?>
  28. <script>
  29. alert('Incorrect password');
  30. window.location='admin.php';
  31. </script>
  32. <?php
  33. }
  34. }
  35. } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement