Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $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('db host removed', 'db username removed', 'db password removed');
- // 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("db name removed", $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 (!$selectusername) {
- // 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 " . $user . " {
- name varchar(30),
- due varchar(50),
- course varchar(50),
- 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";
- //}
- mysql_close($connect);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement