"
end function
'Validate user entries in form fields and generate error pages
For Each key in Request.Form
strName = key
strValue = Request.Form(key)
Session(strName) = strValue
Next
strFirst = Request.Form("strFirst")
strLast = Request.Form("strLast")
strEmail = Request.Form("strEmail")
strAddress1 = Request.Form("strAddress1")
strAddress2 = Request.Form("strAddress2")
strCity = Request.Form("strCity")
strState = Request.Form("strState")
strPostalCode = Request.Form("strPostalCode")
strCountry = Request.Form("strCountry")
strPhone = Request.Form("strPhone")
strShipFirst = Request.Form("strShipFirst")
strShipLast = Request.Form("strShipLast")
strShipAddress = Request.Form("strShipAddress")
strShipCity = Request.Form("strShipCity")
strShipState = Request.Form("strShipState")
strShipPostalCode = Request.Form("strShipPostalCode")
strShipCountry = Request.Form("strShipCountry")
strShipMethod = Request.Form("strShipMethod")
If strFirst = "" then
displayHeader()
Response.Write "
" & "Please enter your first name." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
If strLast = "" then
displayHeader()
Response.Write "" & "Please enter your last name." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
If strEmail = "" OR len(strEmail) <=7 then
displayHeader()
Response.Write "" & "Please enter your email address: e.g., (name@yourDomain.com)." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
If strEmail = "" Or instr(strEmail, "@") = 0 then
displayHeader()
Response.Write "" & "Please enter your email address: e.g., (name@yourDomain.com)." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
If strAddress1 = "" OR len(strAddress1) <=7 then
displayHeader()
Response.Write "" & "Please enter your street address." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
If strAddress2 = "" OR len(strAddress2) <2 then
displayHeader()
Response.Write "" & "Please enter your P.O. Box or Rural Route No. Enter 'NA' if not applicable." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
If strCity = "" OR len(strCity) <=2 then
displayHeader()
Response.Write "" & "Please enter your city or town." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
If strState = "" OR len(strState) <=1 then
displayHeader()
Response.Write "" & "Please enter your state or province." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
If strPostalCode = "" OR len(strPostalCode) <5 then
displayHeader()
Response.Write "" & "Please enter your ZIP (postal) code." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
If strCountry = "" OR len(strCountry) <2 then
displayHeader()
Response.Write "" & "Please enter your country." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
If strPhone = "" OR len(strPhone) < 12 then
displayHeader()
Response.Write "" & "Please enter your phone number with area code; e.g., 512-555-5555." & "
" & "" & "Press your browser's " & "back button " & "to return to form." & "
"
Response.Write "
"
Response.End
end if
%>
<%
set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ConString
intOrderID = Request.form("intOrderID")
set rsOrder = Server.CreateObject("ADODB.Recordset")
rsOrder.Open "SELECT * FROM orders WHERE orderID = " _
& intOrderID, Conn, adOpenStatic, adLockOptimistic, _
adCmdText
if rsOrder.EOF then
Response.Write "There is a problem with your order. "
Response.Write "Please contact customer service."
else
rsOrder("sAmt") = Request.form("intShipping")
rsOrder("tax") = Request.form("intTax")
rsOrder("fName") = Request.form("strFirst")
rsOrder("lName") = Request.form("strLast")
rsOrder("email") = Request.form("strEmail")
rsOrder("address1") = Request.form("strAddress1")
rsOrder("address2") = Request.form("strAddress2")
rsOrder("city") = Request.form("strCity")
rsOrder("state") = Request.form("strState")
rsOrder("postalcode") = Request.form("strPostalCode")
rsOrder("country") = Request.form("strCountry")
rsOrder("phone") = Request.form("strPhone")
rsOrder("sfName") = Request.form("strShipFirst")
rsOrder("slName") = Request.form("strShipLast")
rsOrder("sAddress") = Request.form("strShipAddress")
rsOrder("sCity") = Request.form("strShipCity")
rsOrder("sState") = Request.form("strShipState")
rsOrder("sPostalcode") = Request.form("strShipPostalCode")
rsOrder("sCountry") = Request.form("strShipCountry")
rsOrder("sMethod") = Request.form("strShipMethod")
rsOrder("total") = Request.form("intTotal")
rsOrder("orderDate") = Date
rsOrder("status") = "COMPLETE"
rsOrder.Update
Conn.Execute("DELETE FROM itemsOrdered WHERE " _
& "orderID = " & intOrderID)
set rsItem = Server.CreateObject("ADODB.Recordset")
rsItem.Open "itemsOrdered", Conn, adOpenStatic, adLockOptimistic, adCmdTable
for each item in Request.form("strOrderItem")
strOrderItem = cstr(item)
itemInfo = split(strOrderItem, ",")
rsItem.addNew
rsItem("orderID") = intOrderID
rsItem("productID") = itemInfo(0)
rsItem("quantity") = itemInfo(1)
rsItem.Update
next
rsItem.Close
set rsItem = Nothing
Session.abandon
end if
rsOrder.Close
set rsOrder = Nothing
Conn.Close
set Conn = Nothing
%>
<%= pageTitle %>
Live
Demo
This store and
its products are for demonstration purposes only. You cannot
actually purchase any of the products, nor is there a secure server
to process your order.
More info
Contact us
|
| |
Your order has been received. Please allow 8 business
days for delivery.
|
Thanks for shopping with us!
|