Advertisement
Guest User

login.php

a guest
Apr 18th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <?php
  2. include ('template.php');
  3. if (isset($_POST['username']) and isset($_POST['password']))
  4. {
  5. $query = <<<END
  6. SELECT username, password, id FROM users
  7. WHERE username = '{$_POST['username']}'
  8. AND password = '{$_POST['password']}'
  9. END;
  10. $result =$mysqli->query($query);
  11. if ($result->num_rows > 0)
  12. {
  13. $row = $result->fetch_object();
  14. $_SESSION["username"] = $row->username;
  15. $_SESSION["userId"] = $row->id;
  16. header("Location:index.php");
  17. } else{
  18. echo "wrong username or password, try again";
  19. }
  20. }
  21. $content = <<<END
  22. <form action="login.php" method="post">
  23. <input type="text" name="username" placeholder="username">
  24. <input type="password" name="password" placeholder="password">
  25. <input type="submit" value="Login">
  26. </form>
  27. END;
  28. echo $navigation;
  29. echo $content;
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement