1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
-
- // Login Form
-
- session_start();
-
-
-
- if (isset($_POST['login'])){
-
- //Registratie form
-
- function checkLogin ($username, $password) {
- $db = new SQLite3 ("registration.db");
- $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 username = :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>";
- }
-
-
-
- //$stmt_insert = $db->prepare("INSERT INTO users('login', 'password') VALUES(:usrn, :pass)");
- //$stmt_insert->bindValue(":usrn", $username, SQLITE3_TEXT);
- //$stmt_insert->bindValue(":pass", $password, SQLITE3_TEXT);
- //$res = $stmt_insert->execute();
-
-
- //if ($res){
- // echo "Gebruiker " . $username . " aangemaakt.";
- //} else {
- // $errorCode = $db->lastErrorCode();
- // $errorMessage = $db->lastErrorMsg();
- // echo "Database error wiht ocde " . $errorCode . " and message " . $errorMessage;
- //}
-
- //Wat bij duplicates?
-
- }
-
-
- ?>
-
- <!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="difficulty.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>
|