Advertisement
Guest User

Untitled

a guest
Mar 25th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.15 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     require 'functions.php';
  4.  
  5.     if(isset($_POST['sign-up'])){
  6.  
  7.         // username
  8.         if (!empty($_POST['username'])){
  9.             $username = mysql_real_escape_string(trim($_POST['username']));
  10.             $_SESSION['status']['register']['username'] = $username;
  11.             if(strlen($username) > 3){
  12.                     if(strlen($username) < 31){
  13.                         if(user_exists($username) === true){
  14.                             $_SESSION['status']['register']['error'][] = 'That username is already taken. Sorry, please try again with a different username.';
  15.                         } else{
  16.                         /*passed*/
  17.                     }
  18.                     } else {
  19.                         $_SESSION['status']['register']['error'][] = 'The username is greater than 30 characters.';
  20.                     }
  21.                 } else {
  22.                     $_SESSION['status']['register']['error'][] = 'The username is less than 3 characters.';
  23.                 }
  24.         } else {
  25.             $_SESSION['status']['register']['error'][] = 'There was no username.';
  26.         }
  27.  
  28.         if (!empty($_POST['password'])){
  29.             $password = mysql_real_escape_string(trim($_POST['password']));
  30.  
  31.             if(strlen($password) >= 8){
  32.                     $password = hash_function($password);
  33.                 } else {
  34.                     $_SESSION['status']['register']['error'][] = "Your secret password is too short. You should make a password with at least 8 letters or numbers.";
  35.                 }
  36.  
  37.         } else {
  38.             $_SESSION['status']['register']['error'][] = "You haven't put in a password.";
  39.         }
  40.  
  41.         // Email address
  42.         if (!empty($_POST['email_address'])){
  43.             $email_address = mysql_real_escape_string(trim($_POST['email_address']));
  44.             $_SESSION['status']['register']['email_address'] = $email_address;
  45.             if(strlen($email_address) > 10){ // email address less than 10
  46.                     if(strlen($email_address) < 161){ // if longer than 160
  47.  
  48.                         if(email_valid($email_address) == false){ // email address invalid format
  49.                                 $_SESSION['status']['register']['error'][] = "The email address has been put in wrong. Please check and try again.";
  50.                             }
  51.                             else{
  52.                                 // passed min length, passed max length, passed validation
  53.                                 // Continue
  54.                             }
  55.                     }
  56.                     else
  57.                     {
  58.                         $_SESSION['status']['register']['error'][] = 'The email address is too long.';
  59.                     }
  60.                 }
  61.                 else
  62.                 {
  63.                     $_SESSION['status']['register']['error'][] = "The email address is too short. It can't be shorter than 10 letters or numbers.";
  64.                 }
  65.         }
  66.         else{
  67.         // passed (no email input)
  68.         }
  69.  
  70.         if (isset($_POST['tos'])){
  71.             $_SESSION['status']['register']['tos'] = $_POST['tos'];
  72.             if(empty($_SESSION['status']['register']['error'])){
  73.                 if(register($email_address, $username, $password) === true){
  74.  
  75.                     // Sends an email
  76.                     send_email($email_address);
  77.                     registerSuccessful();
  78.                     $succeeded = true;
  79.  
  80.                     header("Location: register-success.php?username=$username");
  81.                     exit;
  82.  
  83.                 } else {
  84.                     echo mysql_error();
  85.                     die();
  86.                     $_SESSION['status']['register']['error'][] = "Something went wrong. We're sorry. Please try again.";
  87.                 }
  88.             } else {
  89.  
  90.             }
  91.         } else {
  92.             $_SESSION['status']['register']['error'][] = "You have to agree to the House Rules to be able to sign up.";
  93.         }
  94.  
  95.         // If postback needed
  96.         if($succeeded != true){
  97.         header('Location: register-form.php');
  98.         }else {
  99.  
  100.         }
  101.     } else {
  102.     }
  103.  
  104.     ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement