Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $page = "Login";
- include('assets/includes/global.php');
- include('assets/includes/header.php');
- $message = "";
- if (isset($_POST['email'])) {
- $user = $_POST['username'];
- $pass = $_POST['password'];
- if ((!$user) || (!$pass)) {
- $message = "Please complete all fields";
- } else {
- $stmt = $mysqli->prepare("SELECT `id`, `email`, `password` FROM `users` WHERE `username` = ? LIMIT 1");
- $stmt->bind_param('s', $user);
- $stmt->execute();
- $stmt->bind_result($id, $user, $pwhash);
- if ($stmt->fetch()) {
- $stmt->close();
- if ($pwhash !== crypt($pass, $pwhash)) {
- $message = "Invalid Credentials";
- } else {
- $_SESSION['password'] = $pwhash;
- $_SESSION['username'] = $user;
- $_SESSION['id'] = $id;
- header("Location: ./");
- $message = "Session started, you are logged in.";
- }
- } else {
- $message = "Invalid Credentials";
- }
- }
- }
- ?>
- <div id="bodyWrapper">
- <div class="global-form" id="registerform">
- <div class="container">
- <div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
- <form action="login.php" method="POST" role="form" autocomplete="off">
- <img src="https://elcrodevelopment.com/checkout/assets/imgs/logo.png" alt="Logo" width="250" style="padding-bottom: 10px;text-align:center;">
- <p class="form-intro" style="font-size:22px;color:#000;">Login to your Dashboard</p>
- <p style="color:#000;"><?= $message ?></p>
- <fieldset class="form-group">
- <input type="text" class="form-control" name="username" placeholder="Username" required>
- </fieldset>
- <fieldset class="form-group">
- <input type="password" class="form-control" name="password" placeholder="Password" required>
- </fieldset>
- <div id="button">
- <p style="text-align: center;padding-bottom:2px;">Don't have an account? <a href="register.php">Register</a></p>
- <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>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement