123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- session_start();
-
-
- if (isset($_POST['login'])){
-
- //Registratie form
- function checkLogin ($username, $password) {}
- $db = new SQLite3 ("db.sqlite");
- $username = $_POST['username'];
- $password = $_POST['password_1'];
-
- //Login Form
- //$sql = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
- $stmt = $db->prepare("SELECT * FROM users WHERE login = :usrn AND password = :passw");
- $stmt->bindValue(":usrn", $username, SQLITE3_TEXT);
- $stmt->bindValue(":pass", $password, SQLITE3_TEXT);
- $res = $stmt->execute();
-
- if ($row = $res->fetchArray(SQLITE3_ASSOC)){
- $id = $row['id'];
- $res = $db->query("INSERT INTO game('user_id', 'won') VALUES ($id,true)");
- } else {
- echo "Gebruiker bestaat niet";
- echo "<a href=\"index.php\">Sign up</a>";
- }
- }
-
-
- ?>
-
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <header>
- <h2>Login</h2>
- </header>
-
- <form method="POST" action="login.php">
- <div class="input-group">
- <label>Username</label>
- <input type="text" name="username">
- </div>
-
- <div class="input-group">
- <label>Password</label>
- <input type="password" name="password_1">
- </div>
-
- <div class="input-group">
- <button type="submit" name="login" class="btn">Login</button>
- </div>
- <p>
- Not signed up yet? <a href="index.php">Sign up</a>
- </p>
- </form>
-
-
-
-
-
-
-
-
-
- </body>
- </html>
|