Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <?php
  2. require_once("template.php");
  3. if (isset($_POST['username']) and isset($_POST['password'])) {
  4. $name = $mysqli->real_escape_string($_POST['username']);
  5. $pwd = $mysqli->real_escape_string($_POST['password']);
  6. $query = <<<END
  7. SELECT username, password, id FROM users
  8. WHERE username = '{$name}'
  9. AND password = '{$pwd}'
  10. END;
  11. $result = $mysqli->query($query);
  12. if ($result->num_rows > 0) {
  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