Advertisement
Guest User

Untitled

a guest
Apr 18th, 2018
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. }
  18. else
  19. {
  20. echo "Wrong username or password. Try again.";
  21. }
  22. }
  23. $content = <<<END
  24. <form action="login.php" method="post">
  25. <input type="text" name="username" placeholder="username">
  26. <input type="password" name="password" placeholder="password">
  27. <input type="submit" value="Login">
  28. </form>
  29. END;
  30. echo $navigation;
  31. echo $content;
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement