Advertisement
Guest User

Untitled

a guest
Aug 7th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.54 KB | None | 0 0
  1. <?php
  2.  
  3.    
  4.       if(!empty($_POST)  ){
  5.     $_SESSION['email'] = $_Post['email'];
  6.     $_SESSION['first_name'] = $_Post['first_name'];
  7.     $_SESSION['last_name'] = $_Post['last_name'];
  8.    
  9.     if(!empty($_POST['first_name']) && !empty($_POST['last_name']) && !empty($_POST['email'])&& !empty($_POST['username'])
  10.         && !empty($_POST['pass_word']) && !empty($_POST['confirm_pass']) &&
  11.         !empty($_POST['phone_no']) && !empty($_POST['gender'])){
  12.  
  13.      $firstname = mysqli_real_escape_string($link, $_POST['first_name']);
  14.      $lastname =  mysqli_real_escape_string($link, $_POST['last_name']);
  15.      $email =  mysqli_real_escape_string($link, $_POST['email']);
  16.      $username =  mysqli_real_escape_string($link, $_POST['username']);
  17.      $phoneno =  mysqli_real_escape_string($link, $_POST['phone_no']);
  18.      $gender =  mysqli_real_escape_string($link, $_POST['gender']);
  19.      $password =  mysqli_real_escape_string($link, md5($_POST['pass_word'])) ;
  20.      $confirmPassword =  mysqli_real_escape_string($link, md5($_POST['confirm_pass']));
  21.      $activationCode =  mysqli_real_escape_string($link, md5(rand()));
  22.      $status =  mysqli_real_escape_string($link, 'user');
  23.      $active = 0;
  24.          
  25.      //$query = "SELECT * FROM user WHERE email='$email'";
  26.       $query = "SELECT * FROM user WHERE username='$username'";
  27.      $result = mysqli_query($link, $query);
  28.      
  29.      if(mysqli_num_rows($result)>0) {
  30.         $_SESSION['message'] = 'User with this email already exists.';
  31.         header("location: error.php");
  32.      }else{
  33.          
  34.  
  35.         $query = "INSERT into user (firstname, lastname, username, gender, phoneno, email, password, activationCode, status, active) VALUES('$firstname', '$lastname', '$username', '$gender', '$phoneno', '$email', '$password', '$activationCode', '$status', $active)";
  36.         $queryresult = mysqli_query($link, $query);
  37.        
  38.  
  39.         if($queryresult){
  40.                         $_SESSION['active'] = 0;
  41.                         $_SESSION['logged_in'] = true;
  42.                         $_SESSION['message'] =
  43.                         "Confirmation link has been sent to $email, please verify
  44.                         your account by clicking on the link in the message!";
  45.                        
  46.                        
  47.                         $to      = $email;
  48.                         $subject = 'Account Verification ( shoppingcart.com )';
  49.                         $messagebody = '
  50.                         Hello '.$first_name.',
  51.  
  52.                         Thank you for signing up!
  53.  
  54.                         Please click this link to activate your account:
  55.  
  56.                         http://localhost/websiteproject/verify.php?email='.$email.'&activationcode='.$activationCode;
  57.                        
  58.                         header("location: wait.php");
  59.                        
  60.         }else{
  61.            
  62.                         $_SESSION['message'] = 'Registration failed!';
  63.                         header("location: error.php");
  64.         }
  65.      }
  66.      
  67.      
  68.   }
  69.  
  70.       }
  71.    
  72. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement