Advertisement
Guest User

Untitled

a guest
Jul 11th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. // ...
  2.  
  3. // LOGIN USER
  4. if (isset($_POST['login_user'])) {
  5. $username = mysqli_real_escape_string($db, $_POST['username']);
  6. $password = mysqli_real_escape_string($db, $_POST['password']);
  7.  
  8. if (empty($username)) {
  9. array_push($errors, "Username is required");
  10. }
  11. if (empty($password)) {
  12. array_push($errors, "Password is required");
  13. }
  14.  
  15. if (count($errors) == 0) {
  16. $password = md5($password);
  17. $query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
  18. $results = mysqli_query($db, $query);
  19. if (mysqli_num_rows($results) == 1) {
  20. $_SESSION['username'] = $username;
  21. $_SESSION['success'] = "You are now logged in";
  22. header('location: index.php');
  23. }else {
  24. array_push($errors, "Wrong username/password combination");
  25. }
  26. }
  27. }
  28.  
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement