PHP Zeeslag
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

login.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. session_start();
  3. if (isset($_POST['login'])){
  4. //Registratie form
  5. function checkLogin ($username, $password) {}
  6. $db = new SQLite3 ("db.sqlite");
  7. $username = $_POST['username'];
  8. $password = $_POST['password_1'];
  9. //Login Form
  10. //$sql = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
  11. $stmt = $db->prepare("SELECT * FROM users WHERE login = :usrn AND password = :passw");
  12. $stmt->bindValue(":usrn", $username, SQLITE3_TEXT);
  13. $stmt->bindValue(":pass", $password, SQLITE3_TEXT);
  14. $res = $stmt->execute();
  15. if ($row = $res->fetchArray(SQLITE3_ASSOC)){
  16. $id = $row['id'];
  17. $res = $db->query("INSERT INTO game('user_id', 'won') VALUES ($id,true)");
  18. } else {
  19. echo "Gebruiker bestaat niet";
  20. echo "<a href=\"index.php\">Sign up</a>";
  21. }
  22. }
  23. ?>
  24. <!DOCTYPE html>
  25. <html lang="en">
  26. <head>
  27. <meta charset="UTF-8">
  28. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  29. <title>Document</title>
  30. </head>
  31. <body>
  32. <header>
  33. <h2>Login</h2>
  34. </header>
  35. <form method="POST" action="login.php">
  36. <div class="input-group">
  37. <label>Username</label>
  38. <input type="text" name="username">
  39. </div>
  40. <div class="input-group">
  41. <label>Password</label>
  42. <input type="password" name="password_1">
  43. </div>
  44. <div class="input-group">
  45. <button type="submit" name="login" class="btn">Login</button>
  46. </div>
  47. <p>
  48. Not signed up yet? <a href="index.php">Sign up</a>
  49. </p>
  50. </form>
  51. </body>
  52. </html>