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'])){
- // Email address
- if (isset($_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
- }
- }
- 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.";
- }
- }
- else
- {
- $_SESSION['status']['register']['error'][] = "You haven't put in an email address.";
- }
- // username
- if (isset($_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'][] = 'The username is not entered.';
- }
- if (isset($_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.";
- }
- } else {
- $_SESSION['status']['register']['error'][] = "You haven't put in a password.";
- }
- if (isset($_POST['tos'])){
- $_SESSION['status']['register']['tos'] = $_POST['tos'];
- if(empty($_SESSION['status']['register']['error'])){
- if(register($email_address, $username, $password) === true){
- $_SESSION['status']['register']['success'] = true;
- } 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.";
- }
- header('Location: index.php');
- } else {
- header('Location: index.php');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement