123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
-
- // Register Form
-
- session_start();
-
-
-
- if (isset($_POST['register'])){
- $db = new SQLite3 ("registration.db");
- $username = $_POST['username'];
- $email = $_POST['email'];
- $password = $_POST['password_1'];
- $stmt = $db->prepare("INSERT INTO users (username, email, password) VALUES (:usrn, :mail, :pass)");
- $stmt->bindValue(":usrn", $username, SQLITE3_TEXT);
- $stmt->bindValue(":mail", $email, SQLITE3_TEXT);
- $stmt->bindValue(":pass", $password, SQLITE3_TEXT);
- $stmt->execute();
-
-
- if (isset ($_POST['username']) && ($_POST['email']) && ($_POST['password_1'])) {
- echo "You are registered";
- } else {
- $_SESSION['errormsg'] = "Fill in all the requirements.";
- return $_SESSION['errormsg'];
- }
-
- }
-
-
- ?>
- <!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>Register</h2>
- </header>
-
- <form method="POST" action="index.php">
- <div class="input-group">
- <label>Username</label>
- <input type="text" name="username">
- </div>
- <div class="input-group">
- <label>Email</label>
- <input type="text" name="email">
- </div>
- <div class="input-group">
- <label>Password</label>
- <input type="password" name="password_1">
- </div>
- <div class="input-group">
- <label>Confirm Password</label>
- <input type="password" name="password_2">
- </div>
- <div class="input-group">
- <button type="submit" name="register" class="btn">Register</button>
- </div>
- <p>
- Already signed up? <a href="login.php">Sign in</a>
- </p>
- </form>
- </body>
- </html>
|