Advertisement
Guest User

dadads

a guest
Mar 5th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.56 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <head>
  3. <html>
  4. <?php
  5. require ('./private/connection.php');
  6. $error = "";
  7. if (isset($_POST['login'])) {
  8. $error = "";
  9. $username = $_POST['username'];
  10. $password = $_POST['password'];
  11. if ($username == "") {
  12. $error = "Gebruikersnaam mag niet leeg zijn!";
  13. } elseif ($password == "") {
  14. $error = "Wachtwoord mag niet leeg zijn!";
  15. }
  16. if ($error == "") {
  17. try {
  18. $db = new PDO("mysql:host=".database_host."; dbname=".database_name, database_user, database_password);
  19. $stmt = $db->prepare("SELECT user_id, user_name, password FROM users WHERE user_name = :username");
  20. $stmt->execute(array(':username' => $username));
  21. $data = $stmt->fetch(PDO::FETCH_ASSOC);
  22. if ($data == false) {
  23. $error = "Gebruikersnaam en/of wachtwoord klopt niet!";
  24. } else {
  25. if (password_verify($password, $data['password'])) {
  26. $_SESSION['username'] = $data['username'];
  27. $_SESSION['password'] = $data['password'];
  28. echo "het klopt!";
  29. exit;
  30. } else {
  31. $error = "Gebruikersnaam en/of wachtwoord klopt niet!";
  32. }
  33. }
  34. } catch (PDOException $e) {
  35. $error = $e->getMessage();
  36. }
  37. }
  38. }
  39. ?>
  40.  
  41. !DOCTYPE html>
  42. <html>
  43. <head>
  44. <meta charset="UTF-8">
  45. <title>Dashboard: Inloggen</title>
  46. <link rel="stylesheet" type="text/css" href="../css/panel/style.css">
  47. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
  48. <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
  49. </head>
  50.  
  51. <body>
  52. <div class="login">
  53. <h1>Inloggen</h1>
  54. <?php if ($error != "") { ?>
  55. <div class="isa_error"><?php echo $error; ?></div>
  56. <?php } ?>
  57. <form action="" method="post">
  58. <input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['username'] ?>"
  59. autocomplete="off"/><br/><br/>
  60. <input type="password" name="password" value="<?php if (isset($_POST['password'])) echo $_POST['password'] ?>"
  61. autocomplete="off"/><br><br>
  62. <button type="submit" name='login' value="Inloggen" class="btn btn-primary btn-block btn-large">Betreed de
  63. wonderlijke wereld!
  64. </button>
  65. </form>
  66. </div>
  67. <script src="../js/index.js"></script>
  68. </body>
  69. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement