Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.86 KB | None | 0 0
  1. <?php
  2.  
  3.     require_once('recaptchalib.php');
  4.     $privatekey = "6LdVt7kSAAAAAKNfGz_Uk58OdJFHFonIZhFtOHZ8";
  5.     $resp = recaptcha_check_answer ($privatekey,
  6.                                     $_SERVER["REMOTE_ADDR"],
  7.                                     $_POST["recaptcha_challenge_field"],
  8.                                     $_POST["recaptcha_response_field"]);
  9.  
  10.     if (!$resp->is_valid) {
  11.       die ("The reCAPTCHA wasn't entered correctly. Go back and try it again. reCAPTCHA said: " . $resp->error );
  12.     }
  13.  
  14.     $username = $_POST['username'];
  15.     $email = $_POST['email'];
  16.     $password = $_POST['password'];
  17.     $cpassword = $_POST['cpassword'];
  18.  
  19.     $connect = mysql_connect('mysql16.000webhost.com', 'a5530369_accounts', 'yu74daCre8ep6PHAnunazuphEpRAg7ban3jECAJu8esawE7equVu9tuMap6aphAf');
  20.      
  21.  
  22.     if (!$connect) {
  23.         die('Error: Could not connect to MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
  24.     }
  25.  
  26.     mysql_select_db("a5530369_johtaja", $connect);
  27.  
  28.  
  29.     $selectusername = mysql_query("SELECT * FROM users WHERE username='$username'");
  30.  
  31.     if (mysql_num_rows($selectusername) == 1) {
  32.  
  33.         if (!empty($username) && !empty($email) && !empty($password) && !empty($cpassword) && $password == $cpassword) {
  34.          
  35.              
  36.             $sqlquery = "CREATE TABLE " . $username . "
  37.             (
  38.                     name varchar(255),
  39.                     due varchar(255),
  40.                     course varchar(255),
  41.                     description varchar(1000)
  42.             )";
  43.  
  44.             if (!mysql_query($sqlquery,$connect)) {
  45.                 die('Error: Could not query MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
  46.             }
  47.  
  48.              
  49.             $sqlquery1 = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password')";
  50.  
  51.             if (!mysql_query($sqlquery1,$connect)) {
  52.                 die('Error: Could not query MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
  53.             }
  54.  
  55.             $to = $email;
  56.             $subject = "Johtaja Account Information";
  57.             $message = "Thank you for signing up for Johtaja! Here is your account information:\n" .
  58.                     "Username: $username\n" .
  59.                     "Email: $email\n" .     "Password: $password\n" .
  60.                     "You may sign in at Johtaja.x10.mx  Please keep this information in case you need it later.";
  61.             $headers = "From: support@Johtaja.x10.mx";
  62.  
  63.             $status = mail($to, $subject, $message, $headers);
  64.  
  65.             if($status) {
  66.                 echo "Account Created!<br />";
  67.                 echo "Username: " . $username . "<br />";
  68.                 echo "Email: " . $email . "<br />";
  69.                 echo "Account Information Has Been Sent To " . $email . ".<br />";
  70.             }
  71.         }
  72.  
  73.  
  74.         $usrvalues = array($username, $email, $password, $cpassword);
  75.        
  76.         foreach ($usrvalues as $value) {
  77.             if (empty($value) {
  78.                 echo "You have not entered a value for a required field. Please press the back button on your web browser and correct this. </br>";
  79.             }
  80.         }
  81.     } else {
  82.    
  83.         echo "The username " . $username . " is already taken. Please press the back button on your web browser and choose another username";
  84.    
  85.     }
  86.  
  87. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement