Accessing or Creating a Profile During Checkout
Introduction.
At this stage of our process the customer has chosen to select some items
for their shopping basket and they have just pressed the button to check
out. The shopper has two main options to proceed.
Unfortunately, for the developers, we need to make sure we can provide almost all of the same functionality we had in the profile related pages as a part of our checkout process. We will do one major thing that is more restrictive by not allowing the shopper to update their profile during the checkout process unless they leave and come back to the checkout. Fortunately, we will be able to make use of a lot of the same code we have already developed for our profile developments, we will mostly have to change the redirections between pages. An image that represents the overall flow of the checkout process is given in the following. |
The first page you need is called checkout_profile_access.php. This is the page that the shopper is taken to when they press the Check Out button on the basket.php page. |
<html> <!-- profile_access.php - accessing a profile or creating a new profile during checkout --> <head> <title>Accessing or Starting a Profile</title> </head> <?php include("includes/header.php"); ?> <p> </p> <p> </p> <div align="center"> <table border="0" cellpadding="3" cellspacing="0" align="center" width="650" id="layout_table"> <tr> <td width="250" align="center"><b><font size="4" color="#999966"> Create a New Profile</font></b></td> <td width="400" align="center"><b><font size="4" color="#999966">Access an Existing Profile<br></font></b></td> </tr> <tr> <td width="250"> <form method="POST" action="checkout_profile_new.php"> <div align="center"> <table border="0" cellpadding="3" cellspacing="0" align=center width="250" id="table_new"> <tr> <td> </td> </tr> <tr> <td align="center"> <input type="submit" value="Submit" name="cmd_new_profile" style="font-size: 14pt; font-weight: bold"></td> </tr> </table> </div> </form> </td> <td width="400"> <form method="POST" action="checkout_profile_access_validate.php"> <div align="center"> <table border="0" cellpadding="5" cellspacing="0" width="400" id="table_access"> <tr> <td width="175" align=right><b><font size="4">E-Mail:</font></b></td> <td width="225"> <input type="text" name="txt_original_email" size="30" style="font-size: 14pt"></td> </tr> <tr> <td width="175" align="right"><b><font size="4">Password:</font></b></td> <td width="225"> <input type="password" name="txt_original_password" size="12" style="font-size: 14pt"></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="Submit" name="cmd_access_rpofile" style="font-size: 14pt; font-weight: bold"></td> </tr> </table> </div> </form> </td> </tr> <tr> <td > </td> <td align="center"><font color="#999966"><b>Forgotten your password, <a href="email_password.php">click here</a>?</b></font></td> </tr> </table> </div> </body> </html> |
This page is primarily HTML that will result in the following form. |
This creates what are hopefully two obvious
options.
Since this is most like what we have already done in the past we will next develop the code for the shopper to create a new profile in checkout_profile_new.php. |
<html> <!-- profile_new.php - the form page for creating a new profile --> <head><title>Adding Your Profile at Firefox</title></head> <?php include("includes/header.php"); include("includes/connection_config.php"); // initializing a blank error message // this will be used to accumulate the input errors // in order to feed them back to the user $error_message = ""; // checking to make sure the form has actually been submitted if ($submit_new_profile != "") {
} |
This is essentially the same as the
profile_new.php so it won't be discussed in much detail at all at
present. It operates in all the same ways to validate the
user's inputs and give them feedback about any problems. The
only real things that are most important to notice are
Now we want to take the other branch where the shopper tries to access an existing profile. We need a variety of pages to deal with all the possible outcomes associated with a shopper's inputs. The main page of interest in this section is checkout_profile_access_validate.php. This PHP file queries the profile table to see whether the shopper's inputs can be found and redirects the shopper to other pages based on the input's validity. We will discuss this page in more detail after it is used because it is more original in this section. |
<html> <?php include("includes/connection_config.php"); // set the inputted email and password to session variable for later use session_start(); $_SESSION["email_original"] = $txt_original_email; $_SESSION["password_original"] = $txt_original_password; // 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_original_email' AND password = '$txt_original_password')"; // 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 if ($row = mysql_fetch_array($result_set)) {
}
} |
What the page does is it basically
Since it is the easier to work with we will next present the checkout_profile_access_failed.php where the shopper is redirected to try again. |
<html> <!-- profile_access_failed.php - accessing a profile --> <head> <title>Accessing a Profile</title> </head> <?php include("includes/header.php"); ?> <br><p align="center"><font size=5 color="#FF0000"><b>The email and password you entered<br> were not found in our database.</b></font></p> <div align="center"> <table border="0" cellpadding="3" cellspacing="0" align="center" width="400" id="layout_table"> <tr> <td width="400" align="center"><b><font size="4" color="#999966">Access an Existing Profile<br></font></b></td> </tr> <tr> <td width="400"> <form method="POST" action="checkout_profile_access_validate.php"> <div align="center"> <table border="0" cellpadding="5" cellspacing="0" width="400" id="table_access"> <tr> <td width="175" align=right><b><font size="4">E-Mail:</font></b></td> <td width="225"> <input type="text" name="txt_original_email" size="30" style="font-size: 14pt"></td> </tr> <tr> <td width="175" align="right"><b><font size="4">Password:</font></b></td> <td width="225"> <input type="password" name="txt_original_password" size="12" style="font-size: 14pt"></td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" value="Submit" name="cmd_access_profile" style="font-size: 14pt; font-weight: bold"></td> </tr> </table> </div> </form> </td> </tr> <tr> <td align="center"><font color="#999966"><b>Forgotten your password, <a href="email_password.php">click here</a>?</b></font></td> </tr> </table> </div> </body> </html> |
This is largely an HTML form page that allows the
shopper to try again or try to get their password emailed to them if
the database contains their email address. The email_password
related pages are the same as those used when trying to update a
profile in the profile section and won't be presented again. This checkout_profile_access_failed.php page should look like the following. |
This form allows the user to try again or try to
get their password emailed to them. These are the only PHP pages we will present on this webpage. Next we will move to the checkout_profile_display.php that will display billing information before going on in the checkout process. |