Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // currently doesn't work
- // all this code links to the persons database
- // need to be updated to connect to the users
- // Code for the add user form
- $username = 'student';
- $password = 'student';
- // Code that connects to the database
- $pdo = new PDO('mysql:dbname=CSY2028' . ';host=v.je' , $username, $password,
- [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
- $stmt = $pdo->prepare('INSERT INTO users (firstname, surname, email, password, admin)
- VALUES (:firstname, :surname, :email, :password, :admin)
- ');
- $title = 'user';
- $output = '
- <form action="register.php" method="POST">
- <div>
- <label for="firstname">First Name: </label>
- <input type="text" required name="firstname" id="firstname" />
- </div>
- <div>
- <label for="surname">Last Name: </label>
- <input type="text" required name="surname" id="surname" />
- </div>
- <div>
- <label for="email">Email Address: </label>
- <input type="text" required name="email" id="email" />
- </div>
- <div>
- <label for="password"> Password: </label>
- <input type="password" required name="password" id="password" />
- </div>
- <div>
- <label for="AcceptTerm">Do you agree to the terms and conditions? </label>
- <input type="checkbox" required name="AcceptTerm" id="AcceptTerm" />
- </div>
- <input type="submit" name="submit" value="Submit" />
- </form>
- ';
- function isFormValid() {
- return (
- isset($_POST['firstname'])&&
- isset($_POST['surname'])&&
- isset($_POST['email'])&&
- isset($_POST['password'])&&
- isset($_POST['admin'])
- );
- }
- if (isFormValid()) {
- echo 'Thank you for signing up';
- echo '<a href="https://v.je/as1/assignment/login.php"> please click here to login</a> ';
- } else {
- echo 'You have not registed';
- }
- include '../layout.php';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement