Advertisement
Guest User

Untitled

a guest
May 16th, 2017
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.29 KB | None | 0 0
  1. <?php
  2. include('../include/db-connect.php');
  3. //$ip=$_SERVER['REMOTE_ADDR'];
  4. $email = $_POST["email"];
  5. $user = $_POST["username"];
  6. $pass = $_POST["pass"];
  7. $pass1 = $_POST["repass"];
  8. $fav_show = $_POST["favshow"];
  9. $iphone = $_POST["iphone"];
  10. //Check for pass matching
  11. if( $pass == $pass1 )
  12. {
  13.     $password = md5($pass);
  14.     valid_email();
  15. }else{
  16.     echo "Passwords dont match try again";
  17.     exit();
  18. }
  19.  
  20. //Need to validate the email address if it isnt display an error with link to retry
  21. function valid_email()
  22. {
  23.     global $email, $user;
  24.     if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email))
  25.     {
  26.         dupe_check($email,$user);
  27.     }else{
  28.         echo "<center><br /><br />Try again with a valid address<br /><br /><a href=\"register.html\">Retry</a></center>";
  29.     }
  30.  
  31. }
  32.  
  33. //Check for dupes on email and username then start the account create function
  34. function dupe_check($email,$user)
  35. {
  36.     //check for email dupes
  37.     $sql = "SELECT users.email FROM users WHERE users.email = '$email' ";
  38.     $ckemail = mysql_query($sql);
  39.     $num_email = mysql_num_rows($ckemail);
  40.     //check for users dupes
  41.     $sql2 = "SELECT users.username FROM users WHERE users.username = '$user' ";
  42.     $ckuser = mysql_query($sql2);
  43.     $num_user = mysql_num_rows($ckuser);   
  44.     if($num_email != 0)
  45.     {
  46.         echo " Someone is already using this email account please use another \n";
  47.         exit();
  48.     }
  49.     if($num_user == 0)
  50.     {
  51.         create_account($email,$user);
  52.     }else{
  53.         echo " Someone is already using this username please use another \n";
  54.         exit();
  55.     }
  56.    
  57. }
  58.  
  59. //Lets see if the passwords match .. if not this should redirect to another page which will tell the user where they failed and then let them try again.
  60. function create_account($email,$user)
  61. {
  62.     global $iphone, $password;
  63.     echo "FUNCTION create_account $email $user $password $iphone $ip";
  64.     $sql = ("INSERT INTO iphone_new.users ( join_date, username, password, email, iphone )
  65.             VALUES ( CURDATE(), '$user', '$password', '$email', '$iphone' )");
  66.     $adduser = mysql_query($sql);
  67.     emailadmin($user,$email);
  68. }
  69.  
  70.  
  71. function emailadmin($user,$email)
  72. {
  73.     //global $user, $email;
  74.     $admin = "rob@logicalhosting.ca";
  75.     $subject = "New User - iPhone Videos";
  76.     $body = "New user $user with email address of $email\n Just signed up.\n";
  77.     mail($admin, $subject, $body);
  78. }
  79.  
  80.  
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement