dang, i keep getting errors with that code. i removes some spaces that were causing errors (i think). now the errors are gone except now it gives me an error on the last line of code. here is what i have up to this point:
<?php
include 'db.php';
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$password = $_POST['password'];
$business_name = $_POST['business_name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state_province = $_POST['state_province'];
$zip_postal = $_POST['zip_postal'];
$country = $_POST['country'];
/* Let's strip some slashes in case the user entered
any escaped characters. */
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$password = stripslashes($password);
$business_name = stripslashes($business_name);
$address = stripslashes($address);
$city = stripslashes($city);
$state_province = stripslashes($state_province);
$zip_postal = stripslashes($zip_postal);
$country = stripslashes($country);
if(array_key_exists('submittor',$_POST)) {
process_form();
} else {
//initialize variables to avoid errors when printing to form
}//end if
include 'join_form.html'; // Show the form again!
function process_form() {
global $first_name,$last_name,$email_address,$username,$password,$business_name,$address,$city,$state_province,$zip_postal,$country;
/* Do some error checking on the form posted fields */
if((!$first_name) || (!$last_name) || (!$email_address) || (!$username) || (!$password) || (!$business_name) || (!$address) || (!$city) || (!$state_province) || (!$zip_postal) || (!$country)){
echo '<span class="warningLG">You did not submit the following required information!<br /></span>';
if(!$first_name){
echo '<span class="warningSM">First Name</span> is a required field. Please enter it below.<br />';
}
if(!$last_name){
echo '<span class="warningSM">Last Name</span> is a required field. Please enter it below.<br />';
}
if(!$email_address){
echo '<span class="warningSM">Email Address</span> is a required field. Please enter it below.<br />';
}
if(!$username){
echo '<span class="warningSM">Desired Username</span> is a required field. Please enter it below.<br />';
}
if(!$password){
echo '<span class="warningSM">Password</span> is a required field. Please enter it below.<br />';
}
if(!$business_name){
echo '<span class="warningSM">Business Name</span> is a required field. Please enter it below.<br />';
}
if(!$address){
echo '<span class="warningSM">Address</span> is a required field. Please enter it below.<br />';
}
if(!$city){
echo '<span class="warningSM">City</span> is a required field. Please enter it below.<br />';
}
if(!$state_province){
echo '<span class="warningSM">State/Province</span> is a required field. Please enter it below.<br />';
}
if(!$zip_postal){
echo '<span class="warningSM">Zip/Postal</span> is a required field. Please enter it below.<br />';
}
if(!$country){
echo '<span class="warningSM">Country</span> is a required field. Please enter it below.<br /><br />';
}
include 'join_form.html'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // if the error checking has failed, we'll exit the script!
}
/* Let's do some checking and ensure that the user's email address or username
does not exist in the database */
$sql_email_check = mysql_query("SELECT email_address FROM users WHERE email_address='$email_address'");
$sql_username_check = mysql_query("SELECT username FROM users WHERE username='$username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo '<span class="warningLG">Please fix the following errors: </span><br />';
if($email_check > 0){
echo 'Your email address has already been used by another member in our database.<br /><span class="warningSM">Please submit a different Email address!</span><br />';
unset($email_address);
}
if($username_check > 0){
echo 'The username you have selected has already been used by another member in our database.<br /><span class="warningSM">Please choose a different Username!</span><br />';
unset($username);
}
include 'join_form.html'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
/* Everything has passed both error checks that we have done.
It's time to create the account! */
// Enter info into the Database.
$sql = mysql_query("INSERT INTO users (first_name, last_name, email_address, username, password, business_name, address, city, state_province, zip_postal, country, signup_date)
VALUES('$first_name', '$last_name', '$email_address', '$username', '$password', '$business_name', '$address', '$city', '$state_province', '$zip_postal', '$country', now())") or die (mysql_error());
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';
} else {
$userid = mysql_insert_id();
// Let's mail the user!
$subject = "Your Membership at Kidorable.com!";
$message = "Dear $first_name $last_name,
Thank you for registering at our website, [url]http://www.kidorable.com[/url]!
You are two steps away from logging in and accessing our exclusive members area.
To activate your membership, please click here: [url]http://www.kidorable.com/Membership/activate.php?id=[/url]$userid&code=$password
Once you activate your membership, you will be able to login with the following information:
Username: $username
Password: $password
Thanks!
The Webmaster
This is an automated response, please do not reply!";
mail($email_address, $subject, $message, "From: Kidorable Webmaster<admin@kidorable.com>\nX-Mailer: PHP/" . phpversion());
echo '<span class="header1">Your membership information has been mailed to your email address!</span><br /> Please check it and follow the directions!';
}
?>