Advertisement
Guest User

Untitled

a guest
May 18th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Login</title>
  5. </head>
  6. <body>
  7. <meta charset="utf-8">
  8. <?php
  9. include('template.php');
  10. if (isset($_POST['username']) and isset($_POST['password'])) {
  11. $query = <<<END
  12. SELECT username, password, id FROM users
  13. WHERE username = '{$_POST['username']}'
  14. AND password = '{$_POST['password']}'
  15. END;
  16. $result = $conn->query($query);
  17. if ($result->rowCount() > 0) {
  18. $row = $result->fetchObject();
  19. $_SESSION["username"] = $row->username;
  20. $_SESSION["id"] = $row->id;
  21. header("Location:index.php");
  22. } else {
  23. echo "Wrong username or password. Try again";
  24. }
  25. }
  26. $content = <<<END
  27. <form action="login.php" method="post">
  28. <input type="text" name="username" placeholder="username">
  29. <input type="password" name="password" placeholder="password">
  30. <input type="submit" value="Login">
  31. </form>
  32. END;
  33. echo $navigation;
  34. echo $content;
  35. ?>
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement