Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- require 'functions.php';
- if(isset($_POST['sign-up'])){
- // username
- if (!empty($_POST['username'])){
- $username = mysql_real_escape_string(trim($_POST['username']));
- $_SESSION['status']['register']['username'] = $username;
- if(strlen($username) > 3){
- if(strlen($username) < 31){
- if(user_exists($username) === true){
- $_SESSION['status']['register']['error'][] = 'That username is already taken. Sorry, please try again with a different username.';
- } else{
- /*passed*/
- }
- } else {
- $_SESSION['status']['register']['error'][] = 'The username is greater than 30 characters.';
- }
- } else {
- $_SESSION['status']['register']['error'][] = 'The username is less than 3 characters.';
- }
- } else {
- $_SESSION['status']['register']['error'][] = 'There was no username.';
- }
- if (!empty($_POST['password'])){
- $password = mysql_real_escape_string(trim($_POST['password']));
- if(strlen($password) >= 8){
- $password = hash_function($password);
- } else {
- $_SESSION['status']['register']['error'][] = "Your secret password is too short. You should make a password with at least 8 letters or numbers.";
- }
- } else {
- $_SESSION['status']['register']['error'][] = "You haven't put in a password.";
- }
- // Email address
- if (!empty($_POST['email_address'])){
- $email_address = mysql_real_escape_string(trim($_POST['email_address']));
- $_SESSION['status']['register']['email_address'] = $email_address;
- if(strlen($email_address) > 10){ // email address less than 10
- if(strlen($email_address) < 161){ // if longer than 160
- if(email_valid($email_address) == false){ // email address invalid format
- $_SESSION['status']['register']['error'][] = "The email address has been put in wrong. Please check and try again.";
- }
- else{
- // passed min length, passed max length, passed validation
- // Continue
- }
- }
- else
- {
- $_SESSION['status']['register']['error'][] = 'The email address is too long.';
- }
- }
- else
- {
- $_SESSION['status']['register']['error'][] = "The email address is too short. It can't be shorter than 10 letters or numbers.";
- }
- }
- else{
- // passed (no email input)
- }
- if (isset($_POST['tos'])){
- $_SESSION['status']['register']['tos'] = $_POST['tos'];
- if(empty($_SESSION['status']['register']['error'])){
- if(register($email_address, $username, $password) === true){
- // Sends an email
- send_email($email_address);
- registerSuccessful();
- $succeeded = true;
- header("Location: register-success.php?username=$username");
- exit;
- } else {
- echo mysql_error();
- die();
- $_SESSION['status']['register']['error'][] = "Something went wrong. We're sorry. Please try again.";
- }
- } else {
- }
- } else {
- $_SESSION['status']['register']['error'][] = "You have to agree to the House Rules to be able to sign up.";
- }
- // If postback needed
- if($succeeded != true){
- header('Location: register-form.php');
- }else {
- }
- } else {
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement