SHARE
TWEET

php/mysql query

a guest Aug 12th, 2016 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include_once("connect.php");
  3. if (isset($_POST['action'])&&$_POST['action'] == "check") {
  4.     $email = mysql_real_escape_string(strip_tags($_POST['email']));
  5.     $username = mysql_real_escape_string(strip_tags($_POST['username']));
  6.  
  7.     if (strpos($email,"@")!==false) {
  8.         $check_email = explode("@",$email);
  9.         if (strpos($check_email[1],".")===false) {
  10.             echo 3;
  11.             exit();
  12.         }
  13.     } else {
  14.         echo 3;
  15.         exit();
  16.     }
  17.     $email_query = mysql_query("SELECT id FROM users WHERE email='$email' LIMIT 1");
  18.     if (mysql_num_rows($email_query)== 1) {
  19.         //Mail alredy exist
  20.         echo 1;
  21.         exit();
  22.     } else {
  23.         $username_query = mysql_query("SELECT username FROM users WHERE username='username' LIMIT 1");
  24.         if (mysql_num_rows($username_query)== 1) {
  25.             //name alredy exist
  26.             echo 2;
  27.             exit();
  28.         } else {
  29.             //evritin ok
  30.             echo 0;
  31.             exit();
  32.         }
  33.     }
  34. }
  35. if (isset($_POST['action'])&&$_POST['action']=="register") {
  36.     $username = mysql_real_escape_string(strip_tags($_POST['username']));
  37.     $password = mysql_real_escape_string(strip_tags($_POST['password']));
  38.     $email = mysql_real_escape_string(strip_tags($_POST['email']));
  39.  
  40.     $activation_code = md5($username.$password);
  41.  
  42.     $reg_query = mysql_query("INSERT INTO users (username, password, email, activation_code) VALUES ('$username','".md5($password)."','$email','$activation_code')");
  43.     if($reg_query) {
  44.         //user folders, act mail
  45.         $new_userid = mysql_insert_id();
  46.  
  47.         //Usur fuldor
  48.         mkdir("../users/$new_userid",0755);
  49.         mkdir("../users/$new_userid/images",0755);
  50.         mkdir("../users/$new_userid/media",0755);
  51.  
  52.         $to = $email;
  53.         $from = "kakaradarkorbit69@gmail.com";
  54.         $subject = "Account activation";
  55.  
  56.         $message = "<h3>Welcum!</h3><p>Activate ur acc by clikin a link</p><p><a href='localhost?id=$new_userid&activate=$activation_code'>localhost?id=$new_userid&activate=$activation_code</a></p>";
  57.  
  58.         $headers = 'MIME-Version: 1.0'."\r\n";
  59.         $headers .= 'Content-Type: text/html; charset=iso-8859-1'."\r\n";
  60.         $headers .= "From: $from\r\nReply-To: $from";
  61.         mail($to,$subject,$message,$headers);
  62.  
  63.         echo 1;
  64.         exit();
  65.     } else {
  66.         //reg failed
  67.         echo 0;
  68.         exit();
  69.     }
  70. }
  71. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top