Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
704
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.60 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.     //$ip = @REMOTE_ADDR;
  19.  
  20.     // Connect To The MySQL DataBase for assigment
  21.     $connect = mysql_connect('mysql16.000webhost.com', 'a5530369_accounts', 'yu74daCre8ep6PHAnunazuphEpRAg7ban3jECAJu8esawE7equVu9tuMap6aphAf');
  22.      
  23.     // Could not connect, echo an error messsage
  24.  
  25.     if (!$connect) {
  26.         die('Error: Could not connect to MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
  27.     }
  28.  
  29.     // Select the DataBase
  30.  
  31.     mysql_select_db("a5530369_johtaja", $connect);
  32.  
  33.     // Set query variable
  34.  
  35.     $selectusername = mysql_query("SELECT * FROM users WHERE username='$username'");
  36.  
  37.     // If statement making sure that the username isn't already taken
  38.     if (mysql_num_rows($selectusername) == 1) {
  39.  
  40.         // Check to see if the conditions are perfect, a.k.a. there is a Username, there is a Email, there is a Password, there is a Confirmation Passowrd, and the Password and confirmation Passwords match
  41.         if (!empty($username) && !empty($email) && !empty($password) && !empty($cpassword) && $password == $cpassword) {
  42.          
  43.             // Set query for making the assignment table
  44.              
  45.             $sqlquery = "CREATE TABLE " . $username . "
  46.             (
  47.                     name varchar(255),
  48.                     due varchar(255),
  49.                     course varchar(255),
  50.                     description varchar(1000)
  51.             )";
  52.  
  53.             // Could not query, echo an error message
  54.              
  55.             if (!mysql_query($sqlquery,$connect)) {
  56.                 die('Error: Could not query MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
  57.             }
  58.  
  59.             // Query INSERT INTO command
  60.              
  61.             $sqlquery1 = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password')";
  62.  
  63.             // Could not query, echo an error message
  64.              
  65.             if (!mysql_query($sqlquery1,$connect)) {
  66.                 die('Error: Could not query MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
  67.             }
  68.  
  69.             // Set variables for the email
  70.             $to = $email;
  71.             $subject = "Johtaja Account Information";
  72.             $message = "Thank you for signing up for Johtaja! Here is your account information:\n" .
  73.                     "Username: $username\n" .
  74.                     "Email: $email\n" .     "Password: $password\n" .
  75.                     "You may sign in at Johtaja.x10.mx  Please keep this information in case you need it later.";
  76.             $headers = "From: support@Johtaja.x10.mx";
  77.  
  78.             // Send the email
  79.             mail($to, $subject, $message, $headers);
  80.  
  81.             // Tell them that everything went well
  82.             echo "Account Created!<br />";
  83.             echo "Username: " . $username . "<br />";
  84.             echo "Email: " . $email . "<br />";
  85.             echo "Account Information Has Been Sent To " . $email . ".<br />";
  86.         }
  87.  
  88.         // The user didn't enter username
  89.          
  90.         if (empty($username)) {
  91.        
  92.             // Tell them that they must enter a username
  93.             echo "You must enter a password. Please press the back button on your web browser and enter a username.<br />";
  94.         }
  95.      
  96.         // The user didn't enter an email
  97.          
  98.         if (empty($email)) {
  99.                
  100.         // Tell them that they must enter an email
  101.         echo "You must enter an email. Please press the back button on your web browser and enter an email.<br />";
  102.        
  103.         }
  104.      
  105.         // The user didn't enter a password
  106.          
  107.         if (empty($password)) {
  108.          
  109.         // Tell them that they must enter a password
  110.         echo "You must enter a password. Please press the back button on your web browser and enter a password.<br />";
  111.        
  112.         }
  113.      
  114.         // The user didn't confirm their password
  115.          
  116.         if (empty($cpassword)) {
  117.          
  118.         // Tell them that they must confirm thier password
  119.         echo "You must confirm you password. Please press the back button on your web browser and confirm you password.<br />";
  120.        
  121.         }
  122.      
  123.         // The password and confirmed passwords don't match
  124.          
  125.         if ($password != $cpassword) {
  126.          
  127.         // Tell them that the passwords must match
  128.         echo "The password and confirmation password must match. Please press the back button on you web browser and re-enter your password and confirmation password";
  129.        
  130.         }
  131.     }
  132.     // The username is already taken
  133.     else {
  134.    
  135.     echo "The username " . $username . " is already taken. Please press the back button on your web browser and choose another username";
  136.    
  137.     }
  138.  
  139. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement