Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'core/init.php';
- include 'includes/overall/header.php';
- if (empty($_POST) === false) {
- $required_fields = array('username', 'password', 'password_again', 'first_name', 'last_name', 'email');
- foreach ($_POST as $key=>$value) {
- if (empty($value) && in_array($key, $required_fields) === true) {
- $errors[] = 'Fields marked with an asterisk are required';
- break 1;
- }
- }
- if (empty($errors) === true) {
- if (user_exists($_POST['username']) === true) {
- $errors[] = 'Sorry, the username \'' . $_POST['username'] . '\' is already in use.';
- }
- if (preg_match("/\\s/", $_POST['username']) == true) {
- $errors = 'Your username may not contain any spaces';
- }
- if (strlen($_POST['password']) < 8) {
- $errors[] = 'Sorry, Your password is not strong enough. Passwords are required to be atleast eight(8) characters long.';
- }
- if ($_POST['password'] !== $_POST['password_again']) {
- $errors[] = 'Your passwords do not match.';
- }
- if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) {
- $errors[] = 'A valid email address is required for registration';
- }
- if (email_exists($_POST['email']) === true) {
- $errors[] = 'Sorry, the email \'' . $_POST['email'] . '\' is already registered';
- }
- }
- }
- ?>
- <h2>Pilot Registration</h2>
- <?php
- if (isset($_GET['success']) && empty($_GET['success'])) {
- echo 'Registeration Successful!!!';
- } else {
- if (empty($_POST) === false && empty($errors) === true) {
- $register_data = array(
- 'username' => $_POST['username'],
- 'password' => $_POST['password'],
- 'first_name' => $_POST['first_name'],
- 'last_name' => $_POST['last_name'],
- 'email' => $_POST['email']
- );
- register_user($register_data);
- header('Location: index.php');
- exit();
- } else if (empty($errors) === false) {
- echo output_errors($errors);
- }
- ?>
- <form action="" method="post">
- <ul>
- <li>
- Username*:<br>
- <input type="text" name="username" />
- </li>
- <li>
- Password*:<br>
- <input type="password" name="password" />
- </li>
- <li>
- Confirm Password*:<br>
- <input type="password" name="password_again" />
- </li>
- <li>
- First Name*:<br>
- <input type="text" name="first_name" />
- </li>
- <li>
- Last Name*:<br>
- <input type="text" name="last_name" />
- </li>
- <li>
- Email*:<br>
- <input type="text" name="email" />
- </li>
- <li>
- <input type="submit" value="Register" />
- </li>
- </ul>
- </form>
- <?php
- }
- include 'includes/overall/footer.php';?>
Advertisement
Add Comment
Please, Sign In to add comment