Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('recaptchalib.php');
- $privatekey = "6LdVt7kSAAAAAKNfGz_Uk58OdJFHFonIZhFtOHZ8";
- $resp = recaptcha_check_answer ($privatekey,
- $_SERVER["REMOTE_ADDR"],
- $_POST["recaptcha_challenge_field"],
- $_POST["recaptcha_response_field"]);
- if (!$resp->is_valid) {
- die ("The reCAPTCHA wasn't entered correctly. Go back and try it again. reCAPTCHA said: " . $resp->error );
- }
- $username = $_POST['username'];
- $email = $_POST['email'];
- $password = $_POST['password'];
- $cpassword = $_POST['cpassword'];
- //$ip = @REMOTE_ADDR;
- // Connect To The MySQL DataBase for assigment
- $connect = mysql_connect('mysql16.000webhost.com', 'a5530369_accounts', 'yu74daCre8ep6PHAnunazuphEpRAg7ban3jECAJu8esawE7equVu9tuMap6aphAf');
- // Could not connect, echo an error messsage
- if (!$connect) {
- die('Error: Could not connect to MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
- }
- // Select the DataBase
- mysql_select_db("a5530369_johtaja", $connect);
- // Set query variable
- $selectusername = mysql_query("SELECT * FROM users WHERE username='$username'");
- // If statement making sure that the username isn't already taken
- if (mysql_num_rows($selectusername) == 1) {
- // 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
- if (!empty($username) && !empty($email) && !empty($password) && !empty($cpassword) && $password == $cpassword) {
- // Set query for making the assignment table
- $sqlquery = "CREATE TABLE " . $username . "
- (
- name varchar(255),
- due varchar(255),
- course varchar(255),
- description varchar(1000)
- )";
- // Could not query, echo an error message
- if (!mysql_query($sqlquery,$connect)) {
- die('Error: Could not query MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
- }
- // Query INSERT INTO command
- $sqlquery1 = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password')";
- // Could not query, echo an error message
- if (!mysql_query($sqlquery1,$connect)) {
- die('Error: Could not query MySQL database. Please email support@Johtaja.x10.mx and tell them about this.');
- }
- // Set variables for the email
- $to = $email;
- $subject = "Johtaja Account Information";
- $message = "Thank you for signing up for Johtaja! Here is your account information:\n" .
- "Username: $username\n" .
- "Email: $email\n" . "Password: $password\n" .
- "You may sign in at Johtaja.x10.mx Please keep this information in case you need it later.";
- $headers = "From: support@Johtaja.x10.mx";
- // Send the email
- mail($to, $subject, $message, $headers);
- // Tell them that everything went well
- echo "Account Created!<br />";
- echo "Username: " . $username . "<br />";
- echo "Email: " . $email . "<br />";
- echo "Account Information Has Been Sent To " . $email . ".<br />";
- }
- // The user didn't enter username
- if (empty($username)) {
- // Tell them that they must enter a username
- echo "You must enter a password. Please press the back button on your web browser and enter a username.<br />";
- }
- // The user didn't enter an email
- if (empty($email)) {
- // Tell them that they must enter an email
- echo "You must enter an email. Please press the back button on your web browser and enter an email.<br />";
- }
- // The user didn't enter a password
- if (empty($password)) {
- // Tell them that they must enter a password
- echo "You must enter a password. Please press the back button on your web browser and enter a password.<br />";
- }
- // The user didn't confirm their password
- if (empty($cpassword)) {
- // Tell them that they must confirm thier password
- echo "You must confirm you password. Please press the back button on your web browser and confirm you password.<br />";
- }
- // The password and confirmed passwords don't match
- if ($password != $cpassword) {
- // Tell them that the passwords must match
- 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";
- }
- }
- // The username is already taken
- else {
- echo "The username " . $username . " is already taken. Please press the back button on your web browser and choose another username";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement