Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.77 KB | None | 0 0
  1. <?php
  2. // currently doesn't work
  3.  
  4.  
  5. // all this code links to the persons database
  6. // need to be updated to connect to the users
  7. // Code for the add user form
  8. $username = 'student';
  9. $password = 'student';
  10. // Code that connects to the database
  11. $pdo = new PDO('mysql:dbname=CSY2028' . ';host=v.je' , $username, $password,
  12. [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
  13. $stmt = $pdo->prepare('INSERT INTO users (firstname, surname, email, password, admin)
  14. VALUES (:firstname, :surname, :email, :password, :admin)
  15. ');
  16.  
  17. $title = 'user';
  18. $output = '
  19. <form action="register.php" method="POST">
  20.  <div>
  21.    <label for="firstname">First Name: </label>
  22.    <input type="text" required name="firstname" id="firstname" />
  23.  </div>
  24.  <div>
  25.    <label for="surname">Last Name: </label>
  26.    <input type="text" required name="surname" id="surname" />
  27.  </div>
  28.  <div>
  29.    <label for="email">Email Address: </label>
  30.    <input type="text" required name="email" id="email" />
  31.  </div>
  32.  <div>
  33.    <label for="password"> Password: </label>
  34.    <input type="password" required name="password" id="password" />
  35.  </div>
  36.  <div>
  37.    <label for="AcceptTerm">Do you agree to the terms and conditions? </label>
  38.    <input type="checkbox" required name="AcceptTerm" id="AcceptTerm" />
  39.  </div>
  40.  <input type="submit" name="submit" value="Submit" />
  41. </form>
  42. ';
  43.  
  44. function isFormValid() {
  45.   return (
  46.     isset($_POST['firstname'])&&
  47.     isset($_POST['surname'])&&
  48.     isset($_POST['email'])&&
  49.     isset($_POST['password'])&&
  50.     isset($_POST['admin'])    
  51.   );
  52. }
  53.  
  54. if (isFormValid())  {
  55.   echo 'Thank you for signing up';
  56.   echo '<a href="https://v.je/as1/assignment/login.php">   please click here to login</a> ';
  57. } else {
  58.   echo 'You have not registed';
  59. }
  60.  
  61. include '../layout.php';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement