Advertisement
Guest User

Untitled

a guest
May 28th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2.   session_set_cookie_params(900);
  3.   session_start();
  4. ?>
  5.  
  6. <!DOCTYPE html>
  7. <html lang="en">
  8. <head>
  9.   <title>Login</title>
  10. </head>
  11. <body>
  12.   <form method="POST">
  13.     Username: <input type="text" name="user" id="user"><br>
  14.     Password: <input type="password" name="passwd" id ="passwd"><br>
  15.   <input type="submit">
  16.   </form>
  17.  
  18.   <?php
  19.     include_once "connection.php";
  20.     $username = mysqli_real_escape_string($conn, $_POST['user']);
  21.     $password = mysql_real_escape_string($conn, $_POST['passwd']);
  22.     $hash = "SELECT passwd FROM users WHERE username = $username ";
  23.  
  24.  
  25. if (password_verify($password, $hash)) {
  26.         // valid, proceed to login
  27.         $_SESSION['user'] = $_POST[$username];
  28.         header( "Location: session.php" );
  29.         exit;
  30.     } else {
  31.         echo "Gebruikersnaam en/of wachtwoord onjuist.";
  32.         exit;
  33.     }
  34.   ?>
  35. </body>
  36. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement