Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <head>
- <html>
- <?php
- require ('./private/connection.php');
- $error = "";
- if (isset($_POST['login'])) {
- $error = "";
- $username = $_POST['username'];
- $password = $_POST['password'];
- if ($username == "") {
- $error = "Gebruikersnaam mag niet leeg zijn!";
- } elseif ($password == "") {
- $error = "Wachtwoord mag niet leeg zijn!";
- }
- if ($error == "") {
- try {
- $db = new PDO("mysql:host=".database_host."; dbname=".database_name, database_user, database_password);
- $stmt = $db->prepare("SELECT user_id, user_name, password FROM users WHERE user_name = :username");
- $stmt->execute(array(':username' => $username));
- $data = $stmt->fetch(PDO::FETCH_ASSOC);
- if ($data == false) {
- $error = "Gebruikersnaam en/of wachtwoord klopt niet!";
- } else {
- if (password_verify($password, $data['password'])) {
- $_SESSION['username'] = $data['username'];
- $_SESSION['password'] = $data['password'];
- echo "het klopt!";
- exit;
- } else {
- $error = "Gebruikersnaam en/of wachtwoord klopt niet!";
- }
- }
- } catch (PDOException $e) {
- $error = $e->getMessage();
- }
- }
- }
- ?>
- !DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>Dashboard: Inloggen</title>
- <link rel="stylesheet" type="text/css" href="../css/panel/style.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
- <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
- </head>
- <body>
- <div class="login">
- <h1>Inloggen</h1>
- <?php if ($error != "") { ?>
- <div class="isa_error"><?php echo $error; ?></div>
- <?php } ?>
- <form action="" method="post">
- <input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['username'] ?>"
- autocomplete="off"/><br/><br/>
- <input type="password" name="password" value="<?php if (isset($_POST['password'])) echo $_POST['password'] ?>"
- autocomplete="off"/><br><br>
- <button type="submit" name='login' value="Inloggen" class="btn btn-primary btn-block btn-large">Betreed de
- wonderlijke wereld!
- </button>
- </form>
- </div>
- <script src="../js/index.js"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement