// if it has been submitted
// each of the form entries will be examined
// to see which have been omitted
if ($_REQUEST['txt_email'] == "")
{
$error_message = "$error_message<br>You have omitted
your email address.";
}
else
{
// need to connect to the
current data to make sure
// that the email address hasn't already been used
// connecting to the database on
battcave.com
$link = mysql_connect($host, $user, $password);
// creating the query string
$query_string = "SELECT * FROM profile WHERE (email =
'$txt_email')";
// executing the SQL statement
$result_set = mysql_db_query($db_name, $query_string,
$link);
// if the resultset has any entries
then you need to let the Shopper
// know the email address is already in use
while ($row = mysql_fetch_array($result_set))
{
$error_message = "$error_message<br><br>This email
address is already in use.<br>";
}
mysql_close($link);
}
if ($_REQUEST['txt_password'] == "")
{
$error_message = "$error_message<br>You have omitted
your password.";
}
if ($_REQUEST['txt_bill_first_name'] == "")
{
$error_message = "$error_message<br>You have omitted
your billing first name.";
}
if ($_REQUEST['txt_bill_last_name'] == "")
{
$error_message = "$error_message<br>You have omitted
your billing last name.";
}
if ($_REQUEST['txt_bill_address'] == "")
{
$error_message = "$error_message<br>You have omitted
your billing address.";
}
if ($_REQUEST['txt_bill_city'] == "")
{
$error_message = "$error_message<br>You have omitted
your billing city.";
}
if ($_REQUEST['sel_bill_state'] == "no_select")
{
$error_message = "$error_message<br>You have omitted
your billing state.";
}
if ($_REQUEST['txt_bill_zip'] == "")
{
$error_message = "$error_message<br>You have omitted
your billing zipcode.";
}
// this section checks for entries in the
credit card information
if ($_REQUEST['txt_card_name'] == "")
{
$error_message = "$error_message<br>You have omitted
the name on your credit card.";
}
if ($_REQUEST['sel_card_type'] == "no_select")
{
$error_message = "$error_message<br>You have omitted
the your credit card type.";
}
if ($_REQUEST['txt_card_number'] == "")
{
$error_message = "$error_message<br>You have omitted
your credit card number.";
}
// this section of code makes sure the
expiration date
// is after today's date based on comparing the month and year
$month_number = date('m');
$year_number = date('Y');
// converting month names to numbers for
comparison
if ($sel_card_month == "January") $sel_month_number = 1;
if ($sel_card_month == "February") $sel_month_number = 2;
if ($sel_card_month == "March") $sel_month_number = 3;
if ($sel_card_month == "April") $sel_month_number = 4;
if ($sel_card_month == "May") $sel_month_number = 5;
if ($sel_card_month == "June") $sel_month_number = 6;
if ($sel_card_month == "July") $sel_month_number = 7;
if ($sel_card_month == "August") $sel_month_number = 8;
if ($sel_card_month == "September") $sel_month_number = 9;
if ($sel_card_month == "October") $sel_month_number = 10;
if ($sel_card_month == "November") $sel_month_number = 11;
if ($sel_card_month == "December") $sel_month_number = 12;
// testing to see if the card's expiration
month and year precede current month and year
if (($sel_card_year < $year_number) || (($sel_card_year
== $year_number) && ($sel_month_number < $month_number)))
{
$error_message = "$error_message<br><br>Your
card expiration date precedes today's date.<br>";
}
// checking to see if the user has checked
// the box so that shipping information is
// the same as billing
if ($chk_same_as != "")
{
$txt_ship_first_name = $txt_bill_first_name;
$txt_ship_last_name = $txt_bill_last_name;
$txt_ship_address = $txt_bill_address;
$txt_ship_city = $txt_bill_city;
$sel_ship_state = $sel_bill_state;
$txt_ship_zip = $txt_bill_zip;
$txt_ship_phone = $txt_bill_phone;
$txt_ship_fax = $txt_bill_fax;
}
else
{
if ($_REQUEST['txt_ship_first_name'] == "")
{
$error_message = "$error_message<br>You have
omitted your shipping first name.";
}
if ($_REQUEST['txt_ship_last_name'] == "")
{
$error_message = "$error_message<br>You have
omitted your shipping last name.";
}
if ($_REQUEST['txt_ship_address'] == "")
{
$error_message = "$error_message<br>You have
omitted your shipping address.";
}
if ($_REQUEST['txt_ship_city'] == "")
{
$error_message = "$error_message<br>You have
omitted your shipping city.";
}
if ($_REQUEST['sel_ship_state'] == "no_select")
{
$error_message = "$error_message<br>You have
omitted your shipping state.";
}
if ($_REQUEST['txt_ship_zip'] == "")
{
$error_message = "$error_message<br>You have
omitted your shipping zipcode.";
}
}
// displaying an error message on the page
// that gives the user appropriate feedback about what is
missing
if ($error_message != "")
{
echo ("<br><center><font color=ff0000 size=4> $error_message
</font></center>");
}
// if all the required inputs are present
then
// we need to create the session_variables
// that will retain the inputs for use throughout the session
// and write these inputted values to our profile table
else
{
// first we establish the
session variables
// that can be accessed everyplace else in the site
// for this user session
session_start();
$_SESSION["active_profile"] = "active";
$_SESSION["email_original"] = $txt_email;
$_SESSION["password_original"] = $txt_password;
$_SESSION["bill_first_name"] = $txt_bill_first_name;
$_SESSION["bill_last_name"] = $txt_bill_last_name;
$_SESSION["bill_address"] = $txt_bill_address;
$_SESSION["bill_city"] = $txt_bill_city;
$_SESSION["bill_state"] = $sel_bill_state;
$_SESSION["bill_zip"] = $txt_bill_zip;
$_SESSION["bill_phone"] = $txt_bill_phone;
$_SESSION["bill_fax"] = $txt_bill_fax;
$_SESSION["ship_first_name"] = $txt_ship_first_name;
$_SESSION["ship_last_name"] = $txt_ship_last_name;
$_SESSION["ship_address"] = $txt_ship_address;
$_SESSION["ship_city"] = $txt_ship_city;
$_SESSION["ship_state"] = $sel_ship_state;
$_SESSION["ship_zip"] = $txt_ship_zip;
$_SESSION["ship_phone"] = $txt_ship_phone;
$_SESSION["ship_fax"] = $txt_ship_fax;
$_SESSION["card_name"] = $txt_card_name;
$_SESSION["card_type"] = $sel_card_type;
$_SESSION["card_number"] = $txt_card_number;
$_SESSION["card_month"] = $sel_card_month;
$_SESSION["card_year"] = $sel_card_year;
// connecting to the database on
battcave.com
$link = mysql_connect($host, $user, $password);
// creating the query string
$query_string = "INSERT INTO profile
VALUES ('0',
'$txt_email',
'$txt_password',
'$txt_bill_first_name',
'$txt_bill_last_name',
'$txt_bill_address',
'$txt_bill_city',
'$sel_bill_state',
'$txt_bill_zip',
'$txt_bill_phone',
'$txt_bill_fax',
'$txt_ship_first_name',
'$txt_ship_last_name',
'$txt_ship_address',
'$txt_ship_city',
'$sel_ship_state',
'$txt_ship_zip',
'$txt_ship_phone',
'$txt_ship_fax',
'$sel_card_type',
'$txt_card_number',
'$sel_card_month',
'$sel_card_year',
'$txt_card_name',
Now( ))";
// executing the SQL statement
mysql_db_query($db_name, $query_string, $link);
mysql_close($link);
header("location:profile_added.php");
}