⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 process.asp

📁 一套简单的购物车程序
💻 ASP
字号:
<%@ Language=VBScript %>
<!-- #include file="db.inc" -->
<%
For Each key in Request.Form
		strname = key
		strvalue = Request.Form(key)
		Session(strname) = strvalue
	Next

If Request.Form("cardno") = "" OR len(Request.Form("cardno")) <=12 Then
	Response.Redirect "checkout.asp?msg=" & Server.URLEncode ("Please fill in a correct credit card number.")
Elseif Request.Form("cardname") = "" OR len(Request.Form("cardname")) <=12 Then
	Response.Redirect "checkout.asp?msg=" & Server.URLEncode ("Please fill in a correct credit card name.")
Elseif Request.Form("cardexpire") = "" OR len(Request.Form("cardexpire")) <=3 OR len(Request.Form("cardexpire")) >=6 Then
	Response.Redirect "checkout.asp?msg=" & Server.URLEncode ("Please fill in a correct expiry date for the credit card in the format mm/yy.")
Elseif Request.Form("cardaddress") = "" OR len(Request.Form("cardaddress")) <=8 Then
	Response.Redirect "checkout.asp?msg=" & Server.URLEncode ("Please fill in the address for the credit card.")
Else

Dim arrCart, scartItem
arrCart = Session("MyCart")
scartItem = Session("cartItem")


Dim rsorder
Set rsorder = Server.CreateObject ("adodb.recordset")
rsorder.Open "orders", dbc, adOpenKeyset, adLockPessimistic, adCmdTable
	rsorder.AddNew
	rsorder("ocustomerid") = Session("customerid")
	rsorder("odate") = Date
	rsorder("orderamount") = Request.Form("ordertotal")
	rsorder("oshipmethod") = CInt(Request.Form("shipment"))
	rsorder("ocardtype") = Request.Form("paymentm")
	rsorder("ocardno") = Request.Form("cardno")
	rsorder("ocardname") = Request.Form("cardname")
	rsorder("ocardexpires") = Request.Form("cardexpire")
	rsorder("ocardaddress") = Request.Form("cardaddress")
	If Not Request.Form("shipaddress")="" then
	rsorder("oshipaddress") = Request.Form("shipaddress")
	End If
	If Not Request.Form("shiptown")="" then
	rsorder("oshiptown") = Request.Form("shiptown")
	End If
	If Not Request.Form("shipzip")="" then
	rsorder("oshipzip") = Request.Form("shipzip")
	End If
	If Not Request.Form("shipstate")="" then
	rsorder("oshipstate") = Request.Form("shipstate")
	End If
	If Not Request.Form("shipcountry")="" then
	rsorder("oshipcountry") = Request.Form("shipcountry")
	End If
	rsorder.Update
	rsorder.Close
	
	Dim oid, sqlo
	sqlo = "SELECT max(orderID) FROM orders"
	Set rso = dbc.Execute(sqlo)	
	oid = Cint(rso(0))
	rso.Close
	
If oid < 1 Then
	Response.Redirect "error.asp?msg=" & Server.URLEncode ("Error: No order id.")
Else
	Dim rsitem
	Set rsitem = Server.CreateObject ("adodb.recordset")
	rsitem.Open "oitems", dbc, adOpenKeyset, adLockOptimistic , adcmdtable
	For i = 1 To scartItem
		rsitem.AddNew
		rsitem("orderid") = oid
		rsitem("catalogid") = arrCart(cProductid,i)
		rsitem("numitems") = arrCart(cQuantity,i)
		rsitem.Update
	Next
	rsitem.Close
End if

If dbc.Errors.Count > 0 then
	dbc.Close
	set dbc = nothing
	Response.Redirect "error.asp?msg=" & Server.URLEncode ("Not succeeded. Error: ") & dbc.Error.Description
Else
	dbc.close
	set dbc = nothing
	Response.Redirect "thanks.asp"
End If
End If
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -