Advertisement
Guest User

Untitled

a guest
Oct 9th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.28 KB | None | 0 0
  1. <?php
  2. $page = "Login";
  3. include('assets/includes/global.php');
  4. include('assets/includes/header.php');
  5.  
  6. $message = "";
  7.  
  8. if (isset($_POST['email'])) {
  9.     $user = $_POST['username'];
  10.     $pass = $_POST['password'];
  11.    
  12.     if ((!$user) || (!$pass)) {
  13.         $message = "Please complete all fields";
  14.     } else {
  15.         $stmt = $mysqli->prepare("SELECT `id`, `email`, `password` FROM `users` WHERE `username` = ? LIMIT 1");
  16.         $stmt->bind_param('s', $user);
  17.         $stmt->execute();
  18.         $stmt->bind_result($id, $user, $pwhash);
  19.         if ($stmt->fetch()) {
  20.             $stmt->close();
  21.             if ($pwhash !== crypt($pass, $pwhash)) {
  22.                 $message = "Invalid Credentials";
  23.             } else {
  24.                 $_SESSION['password'] = $pwhash;
  25.                 $_SESSION['username'] = $user;
  26.                 $_SESSION['id'] = $id;
  27.                
  28.                 header("Location: ./");
  29.                
  30.                 $message = "Session started, you are logged in.";
  31.             }
  32.         } else {
  33.             $message = "Invalid Credentials";
  34.         }
  35.     }
  36. }
  37.  
  38. ?>
  39.  
  40. <div id="bodyWrapper">
  41.     <div class="global-form" id="registerform">
  42.         <div class="container">
  43.             <div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
  44.                 <form action="login.php" method="POST" role="form" autocomplete="off">
  45.                     <img src="https://elcrodevelopment.com/checkout/assets/imgs/logo.png" alt="Logo" width="250" style="padding-bottom: 10px;text-align:center;">
  46.                     <p class="form-intro" style="font-size:22px;color:#000;">Login to your Dashboard</p>
  47.                     <p style="color:#000;"><?= $message ?></p>
  48.                     <fieldset class="form-group">
  49.                         <input type="text" class="form-control" name="username" placeholder="Username" required>
  50.                     </fieldset>
  51.                     <fieldset class="form-group">
  52.                         <input type="password" class="form-control" name="password" placeholder="Password" required>
  53.                     </fieldset>
  54.                     <div id="button">
  55.                         <p style="text-align: center;padding-bottom:2px;">Don't have an account? <a href="register.php">Register</a></p>
  56.                         <button type="submit" id="clientbutton2" class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3 btn btn-primary">Login</button>
  57.                     </div>
  58.                 </form>
  59.             </div>
  60.         </div>
  61.     </div>
  62. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement