Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //function from other file
- function otherusersData($field,$value,$loot){
- $userData = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `$field` = '$value' LIMIT 1"));
- return $userData[$loot];
- } // Grabs another users information. Useage otherusersData("username","$username","id");
- if(isset($_POST['submit'])){
- include("includes/global/global.php");
- # search the database to see if the user name has been taken or not
- $query = sprintf("SELECT * FROM users WHERE username='%s' LIMIT 1",mysql_real_escape_string($_POST['username']));
- $sql = mysql_query($query);
- $row = mysql_fetch_array($sql);
- #check too see what fields have been left empty, and if the passwords match
- 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']){
- # if a field is empty, or the passwords don't match make a message
- $error = '<p>';
- if(empty($_POST['invitecode'])){
- $error .= 'Please enter a code or request one <a href="">here</a>.<br>';
- }
- if(checkInvite($_POST['invitecode'])==false){
- $error .= 'Invite code either does not exist or has already been used.<br>';
- }
- if(empty($_POST['username'])){
- $error .= 'User Name can\'t be empty<br>';
- }
- if(empty($_POST['f_name'])){
- $error .= 'First Name can\'t be empty<br>';
- }
- if(empty($_POST['l_name'])){
- $error .= 'Last Name can\'t be empty<br>';
- }
- if(empty($_POST['email'])){
- $error .= 'Email can\'t be empty<br>';
- }
- if(empty($_POST['password'])){
- $error .= 'Password can\'t be empty<br>';
- }
- if(empty($_POST['password_check'])){
- $error .= 'You must re-type your password<br>';
- }
- if($_POST['password']!=$_POST['password_check']){
- $error .= 'Passwords don\'t match<br>';
- }
- if($row){
- $error .= 'User Name already exists<br>';
- }
- $error .= '</p>';
- }else{
- # If all fields are not empty, and the passwords match,
- # create a session, and session variables,
- $invite_code = $_POST['invitecode'];
- $username = $_POST['username'];
- $password = $_POST['password'];
- $email = $_POST['email'];
- $f_name = $_POST['f_name'];
- $l_name = $_POST['l_name'];
- $w_url = $_POST['w-url'];
- $twit_url = $_POST['twit-url'];
- $fb_url = $_POST['fb-url'];
- if(!isset($_POST['offical_pub'])){$official_pub = "0";}else{$official_pub = $_POST['offical_pub'];}
- if(!isset($_POST['newsletter'])){$newsletter = "0";}else{$newsletter = $_POST['newsletter'];}
- $register_date = date('m/d/y - h:i A');
- $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'";
- $receiver = otherusersData("username",$username,"id");
- $invite_update = "UPDATE invite SET `active` = '1' AND `receiver_id` = '4' WHERE `key` = '$invite_code'";
- if(mysql_query($sql)){
- mysql_query($invite_update);
- }
- # Redirect the user to a login page
- header("Location: login.php");
- exit;
- }
- }
- ?>
Add Comment
Please, Sign In to add comment