Advertisement
Guest User

login

a guest
Apr 28th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.89 KB | None | 0 0
  1. <?php
  2. include ('template.php');
  3. if (isset($_POST['username']) and isset($_POST['password'])){
  4.     $query = <<<END
  5.     SELECT username, password, id FROM user
  6.     WHERE username = '{$_POST['username']}'
  7.     AND password = '{$_POST['password']}'
  8. END;
  9.     $result =$mysqli->query($query);
  10.     if ($result->num_rows > 0)
  11.         {
  12.         $row=$result->fetch_object();
  13.         $_SESSION["username"]   =       $row->username;
  14.         $_SESSION["userId"]     =       $row->id;
  15.         header("Location:index.php");
  16.         }
  17.         if('admin' ==$_SESSION["userId"])
  18.             header("Location:indexadmin.php")
  19.         {
  20.             $
  21.         }
  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. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement