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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. // Register Form
  3. session_start();
  4. if (isset($_POST['register'])){
  5. $db = new SQLite3 ("registration.db");
  6. $username = $_POST['username'];
  7. $email = $_POST['email'];
  8. $password = $_POST['password_1'];
  9. $stmt = $db->prepare("INSERT INTO users (username, email, password) VALUES (:usrn, :mail, :pass)");
  10. $stmt->bindValue(":usrn", $username, SQLITE3_TEXT);
  11. $stmt->bindValue(":mail", $email, SQLITE3_TEXT);
  12. $stmt->bindValue(":pass", $password, SQLITE3_TEXT);
  13. $stmt->execute();
  14. if (isset ($_POST['username']) && ($_POST['email']) && ($_POST['password_1'])) {
  15. echo "You are registered";
  16. } else {
  17. $_SESSION['errormsg'] = "Fill in all the requirements.";
  18. return $_SESSION['errormsg'];
  19. }
  20. }
  21. ?>
  22. <!DOCTYPE html>
  23. <html lang="en">
  24. <head>
  25. <meta charset="UTF-8">
  26. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  27. <title>Document</title>
  28. </head>
  29. <body>
  30. <header>
  31. <h2>Register</h2>
  32. </header>
  33. <form method="POST" action="index.php">
  34. <div class="input-group">
  35. <label>Username</label>
  36. <input type="text" name="username">
  37. </div>
  38. <div class="input-group">
  39. <label>Email</label>
  40. <input type="text" name="email">
  41. </div>
  42. <div class="input-group">
  43. <label>Password</label>
  44. <input type="password" name="password_1">
  45. </div>
  46. <div class="input-group">
  47. <label>Confirm Password</label>
  48. <input type="password" name="password_2">
  49. </div>
  50. <div class="input-group">
  51. <button type="submit" name="register" class="btn">Register</button>
  52. </div>
  53. <p>
  54. Already signed up? <a href="login.php">Sign in</a>
  55. </p>
  56. </form>
  57. </body>
  58. </html>