Guest User

Untitled

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