Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if (isset($_POST["submit"])) {
- //verbind met database
- require("includes/connect.php");
- //controleer of gegevens kloppen
- $username = $_POST["username"];
- $stmt = $conn->prepare("SELECT `id`, `password` FROM users WHERE username = ?");
- $stmt->bind_param("s", $username);
- $stmt->execute();
- $res = $stmt->get_result();
- $row = $res->fetch_all();
- if (isset($row[0][1])) {
- $correctpassword = $row[0][1];
- //var_dump($correctpassword);
- //var_dump(password_verify($_POST["password"],$correctpassword));
- if (password_verify($_POST["password"],$correctpassword)) {
- $_SESSION["session_id"] = session_id();
- $_SESSION["user_id"] = $row[0][0];
- $_SESSION["user"] = $_POST["username"];
- //die("Je bent inlgelogt!<br>Klik <a href=\"index.php\">hier</a> om terug te gaan");
- header("location: index.php");
- }
- else{
- echo("<span class='error'>Username or password in incorrect.</span>");
- }
- /*
- if ($correctpassword == password_hash($_POST["password"],PASSWORD_DEFAULT) {
- echo "wachtwoord goed";
- }
- */
- }
- else {
- echo("Username or password in incorrect.");
- }
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Login</title>
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" type="text/css" media="screen" href="styles/main.css" />
- <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="main.js"></script>
- </head>
- <body>
- <form method="POST" action="">
- <h1>Login</h1>
- <input type="text" name="username" placeholder="username" maxlength="50" required><br>
- <input type="password" name="password" placeholder="password" required><br>
- <input type="submit" name="submit">
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement