Talk:Swapshire

PHP Code
// Connect to database include_once "scripts/connect_to_mysql.php"; $emailCHecker = mysql_real_escape_string($email1); $emailCHecker = str_replace("`", "", $emailCHecker); // Database duplicate username check setup for use below in the error handling if else conditionals $sql_uname_check = mysql_query("SELECT username FROM myMembers WHERE username='$username'"); $uname_check = mysql_num_rows($sql_uname_check); // Database duplicate e-mail check setup for use below in the error handling if else conditionals $sql_email_check = mysql_query("SELECT email FROM myMembers WHERE email='$emailCHecker'"); $email_check = mysql_num_rows($sql_email_check);

// Error handling for missing data if ((!$username) || (!$gender) || (!$b_m) || (!$b_d) || (!$b_y) || (!$email1) || (!$email2) || (!$pass1) || (!$pass2)) {

$errorMsg = 'ERROR: You did not submit the following required information:

';    if(!$username){ $errorMsg .= ' * User Name ';    }     if(!$gender){ $errorMsg .= ' * Gender: Confirm your sex. ';    } 		 if(!$b_m){ $errorMsg .= ' * Birth Month ';          }	 if(!$b_d){ $errorMsg .= ' * Birth Day ';            } 	 if(!$b_y){ $errorMsg .= ' * Birth year ';            } 			 if(!$email1){ $errorMsg .= ' * Email Address ';          }	 if(!$email2){ $errorMsg .= ' * Confirm Email Address ';            } 		 if(!$pass1){ $errorMsg .= ' * Login Password ';          }	 if(!$pass2){ $errorMsg .= ' * Confirm Login Password ';            } 	     } else if ($email1 != $email2) { $errorMsg = 'ERROR: Your Email fields below do not match ';    } else if ($pass1 != $pass2) { $errorMsg = 'ERROR: Your Password fields below do not match ';    } else if ($humancheck != "") { $errorMsg = 'ERROR: The Human Check field must be cleared to be sure you are human ';		     } else if (strlen($username) < 4) { $errorMsg = " ERROR: Your User Name is too short. 4 - 20 characters please. "; } else if (strlen($username) > 20) { $errorMsg = " ERROR: Your User Name is too long. 4 - 20 characters please. "; } else if ($uname_check > 0){ $errorMsg = " ERROR: Your User Name is already in use inside of our system. Please try another. "; } else if ($email_check > 0){ $errorMsg = " ERROR: Your Email address is already in use inside of our system. Please use another. "; } else { // Error handling is ended, process the data and add member to database ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////    $email1 = mysql_real_escape_string($email1); $pass1 = mysql_real_escape_string($pass1); // Add MD5 Hash to the password variable $db_password = md5($pass1); // Convert Birthday to a DATE field type format(YYYY-MM-DD) out of the month, day, and year supplied $full_birthday = "$b_y-$b_m-$b_d";

// GET USER IP ADDRESS $ipaddress = getenv('REMOTE_ADDR');

// Add user info into the database table for the main site table $sql = mysql_query("INSERT INTO myMembers (username, gender, birthday, email, password, ipaddress, sign_up_date)     VALUES('$username','$gender','$full_birthday','$email1','$db_password', '$ipaddress', now)") or die (mysql_error); $id = mysql_insert_id;