", print_r($_POST, true), ""; // Set the database access information as constants: DEFINE ('DB_USER', 'rcfraley'); DEFINE ('DB_PASSWORD', '*password*'); DEFINE ('DB_HOST', 'yourpersonality.netfirmsmysql.com'); DEFINE ('DB_NAME', 'ullman'); // Make the connection: $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() ); // Include external style sheet print " "; print "
"; print "
"; print "
"; #------------------------ # Create a new account (passed info) #------------------------ if($submit_create == 1 AND (empty($email) OR empty($fn)) ) { $error[] = "You must enter an email address and a first name or nickname. "; } if($submit_create == 1 AND !empty($e) AND !empty($fn) ) { // Need to make sure the account/email doesn't already exist // If it does, create an error message. // If it does not, proceed. $q = "SELECT pass, user_id FROM users WHERE email='$e'"; $r = @mysqli_query ($dbc, $q); // Run the query. if ($r) { // If it ran OK. // do nothing }else{ print "Error querring database
"; } $num = mysqli_num_rows($r); if($num > 0){ $error[] = "An account with that email address already exists. Please try again."; }else{ // If the account does not already exist, // create a temporary password and // insert a new row into the data table containing the user's registration info // Create a temporary password automatically // and hash it ($pp) function randString($length, $charset='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') { $str = ''; $count = strlen($charset); while ($length--) { $str .= $charset[mt_rand(0, $count-1)]; } return $str; } $p = randString(8); $pp = SHA1($p); // Create a query string. // Insert user information (and password) into database $q = "INSERT INTO users (first_name,email,pass,registration_date) VALUES ('$fn','$e','$pp',NOW() )"; $r = @mysqli_query ($dbc, $q); // Run the query. if ($r) { // If it ran OK. // if all is okay, flag this variable to 1 // This will signal to the script to send an email $send_new_account_email = 1; }else{ print "Error querring database
"; } } } // Present the form for collecting email and name information // We will only present this if we haven't already passed our checkpoint // for having created a new account. if($send_new_account_email != 1){ print "Create an Account

What is your e-mail address?
My e-mail address is:

"; print "Please enter your first name or nickname.
My name is:


"; print "
"; // Print any error messages that we have from previous submits and database queries if(!empty($error)){ print "
The following errors occurred:
"; foreach($error as $msg){ print "
    $msg
"; } print "
"; } } // If we were able to create the account successfully, send an email to the // user with information about how to login, change passwords, etc. if($send_new_account_email == 1){ $to = $e; $subject = "Registration at yourPersonality.net"; $body = "You have created an account at yourPersonality.net.\n\nPlease visit the site to login with the password below. We strongly encourage you to change your password to one of your chosing after loging in.\n\nLogin: http://yourpersonality.net/test1/ \nTemporary Password = $p \n\nIf you believe you have received this email in error (e.g., you did not sign up on our website), please let us know."; mail($to,$subject,$body,'From: noreply@yourpersonality.net'); print "Account Created

An email has been sent to $e. Please follow the instructions in that e-mail for logging in and setting your account password.

Please note that if you do not receive the e-mail within a few minutes, be sure to check your spam folder. [For website testing purposes: temp password = $p]

Sign in"; } print "
"; mysqli_close($dbc); // Close the database connection. ?>