Advertisement
Guest User

Untitled

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