Advertisement
xiaozhou0211

login.php

Sep 10th, 2017
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.12 KB | None | 0 0
  1. <?php include("includes/header.php") ?>
  2.  
  3. <?php
  4.  
  5. if($session->is_signed_in()){
  6.     redirect("index.php");
  7. }
  8.  
  9. if(isset($_POST['submit'])){
  10.     $username = trim($_POST['username']);
  11.     $password = trim($_POST['password']);
  12.  
  13.     //check the database user
  14.     $user_found = User::verify_user($username,$password);
  15.  
  16.  
  17.     if($user_found){
  18.         $session->login($user_found);
  19.         redirect("index.php");
  20.     }else{
  21.         $the_message = "Your password or username are incorrect";
  22.  
  23.     }
  24. }else{
  25.     $the_message = "";
  26.     $username = "";
  27.     $password ="";
  28. }
  29.  
  30. ?>
  31.  
  32. <div class="col-md-4 col-md-offset-3">
  33.  
  34.     <h4 class="bg-danger"><?php echo $the_message; ?></h4>
  35.        
  36.         <form id="login-id" action="" method="post">
  37.            
  38.             <div class="form-group">
  39.                 <label for="username">Username</label>
  40.                 <input type="text" class="form-control" name="username">
  41.  
  42.             </div>
  43.  
  44.             <div class="form-group">
  45.                 <label for="password">Password</label>
  46.                 <input type="password" class="form-control" name="password">           
  47.             </div>
  48.  
  49.             <div class="form-group">
  50.             <input type="submit" name="submit" value="Submit" class="btn btn-primary">
  51.  
  52.             </div>
  53.  
  54.         </form>
  55.  
  56. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement