Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title> Login </title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
- <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
- </head>
- <body class="login">
- <div class="container container-login">
- <form class="needs-validation" action="login.php" method="POST" name="myFormLogin" id="myFormLogin" novalidate>
- <!-- <div class="form-group has-feedback"> -->
- <label for="validationCustom01" >Username</label>
- <input name="username" type="email" class="form-control" id="validationCustom01" placeholder="Enter email" required=true value="<?php if(isset($username)) echo $username;?>">
- <div class="invalid-feedback">
- This is not an email. ex: a@gmail.com
- </div>
- <div class="form-group has-feedback">
- <label >Password</label>
- <input name="passWord" type="password" class="form-control" placeholder="Password" required=true value="<?php if(isset($password)) echo $password;?>">
- <div class="form-check">
- <label class="form-check-label">
- <input type="checkbox" name="rememberMe" class="form-check-input" <?php if(isset($rememberMe)) echo $rememberMe;?> >
- Remember me
- </label>
- <div class="form-group">
- <button type="submit" class="btn btn-primary"> Submit </button>
- <button type="reset" class="btn btn-danger"> Reset </button>
- </div>
- </form>
- </div>
- </body>
- </html>
- <script>
- // Example starter JavaScript for disabling form submissions if there are invalid fields
- (function() {
- 'use strict';
- window.addEventListener('load', function() {
- // Fetch all the forms we want to apply custom Bootstrap validation styles to
- var forms = document.getElementsByClassName('needs-validation');
- // Loop over them and prevent submission
- var validation = Array.prototype.filter.call(forms, function(form) {
- form.addEventListener('submit', function(event) {
- if (form.checkValidity() === false) {
- event.preventDefault();
- event.stopPropagation();
- }
- form.classList.add('was-validated');
- }, false);
- });
- }, false);
- })();
- </script>
- <?php
- if($_SERVER["REQUEST_METHOD"] == "POST")
- {
- require_once 'config.php';
- $username=$_POST['username'];
- $password=$_POST['passWord'];
- $hashed_password = password_hash($password, PASSWORD_DEFAULT);
- $sql="select * from users where username=:username";
- $stmt= $pdo->prepare($sql);
- $stmt->bindParam(':username',$username,PDO::PARAM_STR);
- $stmt->execute();
- if($stmt->rowCount() == 1)
- {
- $row= $stmt->fetch();
- $hasspassword=$row['password'];
- // var_dump($hasspassword);
- if(password_verify($password, $hashed_password))
- {
- session_start();
- $_SESSION['username']= $username;
- header('Location:mytable.php');
- }
- else
- header('Location:login.php');
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement