Guest User

Untitled

a guest
Jun 23rd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.23 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit'])){
  3.       include("includes/global/global.php");  
  4.     # search the database to see if the user name has been taken or not
  5.    $query = sprintf("SELECT * FROM users WHERE username='%s' LIMIT 1",mysql_real_escape_string($_POST['username']));
  6.     $sql = mysql_query($query);
  7.     $row = mysql_fetch_array($sql);
  8.     #check too see what fields have been left empty, and if the passwords match
  9.    if($row||empty($_POST['username'])|| empty($_POST['f_name'])||empty($_POST['l_name'])|| empty($_POST['email'])|| empty($_POST['invitecode'])|| empty($_POST['email'])||empty($_POST['password'])|| empty($_POST['password_check'])||$_POST['password']!=$_POST['password_check']){
  10.         # if a field is empty, or the passwords don't match make a message
  11.        $error = '<p>';
  12.         if(empty($_POST['invitecode'])){
  13.             $error .= 'Please enter a code or request one <a href="">here</a>.<br>';
  14.         }
  15.         if(checkInvite($_POST['invitecode'])==false){
  16.             $error .= 'Invite code either does not exist or has already been used.<br>';
  17.         }  
  18.         if(empty($_POST['username'])){
  19.             $error .= 'User Name can\'t be empty<br>';
  20.         }
  21.         if(empty($_POST['f_name'])){
  22.             $error .= 'First Name can\'t be empty<br>';
  23.         }
  24.         if(empty($_POST['l_name'])){
  25.             $error .= 'Last Name can\'t be empty<br>';
  26.         }
  27.         if(empty($_POST['email'])){
  28.             $error .= 'Email can\'t be empty<br>';
  29.         }
  30.         if(empty($_POST['password'])){
  31.             $error .= 'Password can\'t be empty<br>';
  32.         }
  33.         if(empty($_POST['password_check'])){
  34.             $error .= 'You must re-type your password<br>';
  35.         }
  36.         if($_POST['password']!=$_POST['password_check']){
  37.             $error .= 'Passwords don\'t match<br>';
  38.         }
  39.         if($row){
  40.             $error .= 'User Name already exists<br>';
  41.         }
  42.         $error .= '</p>';
  43.     }else{
  44.         # If all fields are not empty, and the passwords match,
  45.        # create a session, and session variables,
  46.         $invite_code = $_POST['invitecode'];
  47.         $username = $_POST['username'];
  48.         $password = $_POST['password'];
  49.         $email = $_POST['email'];
  50.         $f_name = $_POST['f_name'];
  51.         $l_name = $_POST['l_name'];
  52.         $w_url = $_POST['w-url'];
  53.         $twit_url = $_POST['twit-url'];
  54.         $fb_url = $_POST['fb-url'];
  55.         if(!isset($_POST['offical_pub'])){$official_pub = "0";}else{$official_pub = $_POST['offical_pub'];}
  56.         if(!isset($_POST['newsletter'])){$newsletter = "0";}else{$newsletter = $_POST['newsletter'];}
  57.         $register_date = date('m/d/y - h:i A');
  58.         $sql = "INSERT INTO users SET `username`='$username',`password` = '$password', `first_name` = '$f_name', `last_name` = '$l_name', `w_url` = '$w_url', `twit_url` = '$twit_url', `fb_url` = '$fb_url', `official_pub` = '$official_pub', `email` = '$email', `newsletter` = '$newsletter', `register_date` = '$register_date'";
  59.         $receiver = otherusersData("username",$username,"id");
  60.         $invite_update = "UPDATE invite SET `active` = '1' AND `receiver_id` = '4' WHERE `key` = '$invite_code'";
  61.         if(mysql_query($sql)){
  62.             mysql_query($invite_update);
  63.         }
  64.         # Redirect the user to a login page
  65.        header("Location: login.php");
  66.         exit;
  67.     }
  68. }
  69.  
  70. ?>
Add Comment
Please, Sign In to add comment