Advertisement
michaelyuen

Untitled

Oct 6th, 2017
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. <?php
  2. function login_user($username, $password) {
  3.     $sqlQuery = "SELECT * FROM users WHERE username = ? AND password = ?";
  4.     $statement = $db->prepare($sqlQuery);
  5.     $statment->bindParam(1, $username);
  6.     $statment->bindParam(2, $password);
  7.     $statement->execute();
  8.     $data = $statement->fetch();
  9.     if ($data) {
  10.         return true;
  11.     }
  12.     return false;
  13. }
  14.  
  15. if (isset($_POST['submit'])) {
  16.     $username = $_POST['username'];
  17.     $password = $_POST['password'];
  18.     // execute your function
  19.     if (login_user($username, $password)) {
  20.         header("location:admin");
  21.     }
  22. }
  23.  
  24. header("location:login.php");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement