<%@ Language=VBScript %>
<%
' Retrieve the submitted items from Shipping.asp
chrShipFirstName = request("chrShipFirstName")
chrShipLastName = request("chrShipLastName")
chrShipAddress = request("chrShipAddress")
chrShipCity = request("chrShipCity")
chrShipState = request("chrShipState")
chrShipProvince = request("chrShipProvince")
chrShipCountry = request("chrShipCountry")
chrShipZipCode = request("chrShipZipCode")
chrShipPhone = request("chrShipPhone")
chrShipEmail = request("chrShipEmail")
' Accumulating the error message and checking for blank entries
' Check to ensure a first name was entered.
if chrShipFirstName = "" then
strError = strError & "Invalid first name<BR>"
end if
' Check to ensure a last name was entered.
if chrShipLastName = "" then
strError = strError & "Invalid last name<BR>"
end if
' Check to ensure an address was entered.
if chrShipAddress = "" then
strError = strError & "Invalid address<BR>"
end if
' Check to ensure a city was entered.
if chrShipCity = "" then
strError = strError & "Invalid city<BR>"
end if
' Check to see if a US country was entered.
if chrShipCountry = "US" then
' If the state field is empty then build the appropriate error message.
if chrShipState = "" then
strError = strError & "Invalid state<BR>"
end if
else
' If it is an international country is entered then a province must be entered.
if chrShipProvince = "" then
strError = strError & "Invalid province<BR>"
end if
end if
' Check to see if a country was entered.
if chrShipCountry = "" then
strError = strError & "Invalid country<BR>"
end if
' Check to ensure a zip code was entered.
if chrShipZipCode = "" then
strError = strError & "Invalid zip code<BR>"
end if
' Check to ensure a phone number was entered.
if chrShipPhone = "" then
strError = strError & "Invalid phone number<BR>"
end if
' Next we validate the email address.
' The email address must have a @ symbol or period.
if (instr(1, chrShipEmail, "@") = 0) or (instr(1, chrShipEmail, ".") = 0) then
strError = strError & "Invalid email address<BR>"
end if
' Check to ensure that only one of the state or province fields are filled in.
if (chrShipState <> "") and (chrShipProvince <> "") then
strError = strError & "You can not fill in both the " & _
"state and province fields<BR>"
end if
' Copy the shipping values to session variables
session("chrShipFirstName") = request("chrShipFirstName")
session("chrShipLastName") = request("chrShipLastName")
session("chrShipAddress") = request("chrShipAddress")
session("chrShipCity") = request("chrShipCity")
session("chrShipState") = request("chrShipState")
session("chrShipProvince") = request("chrShipProvince")
session("chrShipCountry") = request("chrShipCountry")
session("chrShipZipCode") = request("chrShipZipCode")
session("chrShipPhone") = request("chrShipPhone")
session("chrShipEmail") = request("chrShipEmail")
' Check to see if an error was generated
and route the shopper accordingly
if strError <> "" then
' Store the error in a session variable and then direct the shopper back ot the shipping page.
session("Error") = strError
Response.Redirect "shipping.asp"
else
' All of the data is correct, so we copy the shipping data
' to billing variables to default the data on the payment form.
' That way the user does not have to retype their billing information
' if it is the same.
session("chrBillFirstName") = request("chrShipFirstName")
session("chrBillLastName") = request("chrShipLastName")
session("chrBillAddress") = request("chrShipAddress")
session("chrBillCity") = request("chrShipCity")
session("chrBillState") = request("chrShipState")
session("chrBillProvince") = request("chrShipProvince")
session("chrBillCountry") = request("chrShipCountry")
session("chrBillZipCode") = request("chrShipZipCode")
session("chrBillPhone") = request("chrShipPhone")
session("chrBillEmail") = request("chrShipEmail")
' Send the user to the payment page.
Response.Redirect "Payment.asp"
end if
%> |