orders3.asp:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/conn.asp" -->
<% dim name1,total,email,province,city,address,zip,phone
name1=request("name1")
total=request("total")
email=request("email")
province=request("province")
city=request("city")
address=request("address")
zip=request("zip")
phone=request("phone")
set conn=server.CreateObject("adodb.connection")
conn.open MM_conn_STRING
set rsorder=server.CreateObject("adodb.recordset")
sql="select * from Orders"
rsorder.open sql,conn,3,2
rsorder.addnew
rsorder("Odate")=date
rsorder("Total")=total
rsorder("CName")=name1
rsorder("Email")=email
rsorder("Province")=province
rsorder("City")=city
rsorder("Address")=address
rsorder("Zip")=zip
rsorder("Phone")=phone
rsorder.update
rsorder.movelast
OrderID=rsorder("OrderID")
rsorder.close
CartID=session("CartID")
if CartID="" then CartID=0
set rsitem=server.CreateObject("adodb.recordset")
sql="select * from CartsItems where CartID="&CartID
rsitem.open sql,conn,0,1
while not rsitem.eof
sql="insert into OrderItems(OrderID,ProductID,PName,Price,Quantity)values("& OrderID &","& rsitem("ProductID") &", '"& rsitem("Name1") &"',"& rsitem("Price") &","& rsitem("Quantity") &")"
conn.execute sql
rsitem.movenext
wend
rsitem.close
set conn=nothing
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>訂單生成</title>
</head>
<body>
<font color="#000000" size="4" face="華文宋體">感謝惠顧!您的訂單號是:<%=OrderID%><br />
請記住您的訂單號,以便必要時查詢。<br />
請單擊<a href="https://bbs.csdn.net/topics/orders4.asp">這里</a>回傳。</font>
</body>
</html>
為什么Orders資料表里沒有資料啊?只有一個日期。

相關頁面代碼如下:
orders2.asp:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/conn.asp" -->
<%
Dim rs__MMColParam
rs__MMColParam = "1"
If (Session("CartID") <> "") Then
rs__MMColParam = Session("CartID")
End If
%>
<%
Dim rs
Dim rs_cmd
Dim rs_numRows
Set rs_cmd = Server.CreateObject ("ADODB.Command")
rs_cmd.ActiveConnection = MM_conn_STRING
rs_cmd.CommandText = "SELECT * FROM CartsItems WHERE CartID = ?"
rs_cmd.Prepared = true
rs_cmd.Parameters.Append rs_cmd.CreateParameter("param1", 5, 1, -1, rs__MMColParam) ' adDouble
Set rs = rs_cmd.Execute
rs_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
rs_numRows = rs_numRows + Repeat1__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>確認訂單</title>
<style type="text/css">
p {
font-weight: bold;
text-align: center;
}
td {
font-size: 18px;
line-height: 24px;
color: #15007b;
font-weight: bold;
}
</style></head>
<body>
<form id="form1" name="form1" method="post" action="orders3.asp">
<p><font color="#800080" size="5" face="華文宋體">您的訂單如下</font></p>
<table width="75%" border="1" align="center">
<tr>
<td width="40" align="center" bgcolor="#cccccc">序號</td>
<td align="center" bgcolor="#cccccc">商品名稱</td>
<td align="center" bgcolor="#cccccc">單價</td>
<td align="center" bgcolor="#cccccc">數量</td>
<td align="center" bgcolor="#cccccc">金額</td>
</tr>
<% i=1
total=0
While ((Repeat1__numRows <> 0) AND (NOT rs.EOF))
sum=rs("Price")*rs("Quantity")
%><tr>
<td align="center"><%=formatnumber(i,0)%> </td>
<td align="center"><%=(rs.Fields.Item("Name1").Value)%></td>
<td align="center"><%=formatcurrency(rs.Fields.Item("Price").Value,2)%></td>
<td align="center"><%=(rs.Fields.Item("Quantity").Value)%></td>
<td align="center"><%=formatcurrency(sum,2)%> </td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rs.MoveNext()
i=i+1
total=total+sum
Wend
%>
<tr>
<td colspan="4" align="center" bgcolor="#e4e4e4">總計</td>
<td align="center" bgcolor="#e4e4e4"><%=formatcurrency(total,2)%> </td>
</tr>
</table>
<p> </p>
<table width="75%" border="0" cellpadding="0" cellspacing="0" align="center" >
<tr>
<td align="center" bgcolor="#cccccc">您的送貨資訊</td>
</tr>
</table>
<table width="75%" border="0" cellpadding="0" cellspacing="0" align="center" >
<tr>
<td width="40%" height="180" align="right" bgcolor="#cccccc">
<%
dim name1,email,province,city,address,zip,phone
name1=request("name1")
email=request("email")
province=request("province")
city=request("city")
address=request("address")
zip=request("zip")
phone=request("phone")
if name1=empty or email=empty or province=empty or city=empty or address=empty or zip=empty or phone=empty then
response.Write"請完善訂單資訊!<br>請單擊<a href='https://bbs.csdn.net/topics/orders1.asp'>這里</a>回傳填寫。"
response.End
end if
%>
</td>
<td width="60%" height="180" bgcolor="#cccccc"><%
response.Write"真實姓名:"&name1&"<br>"
response.Write"電子郵件:"&email&"<br>"
response.Write"所在省份:"&province&"<br>"
response.Write"所在城市:"&city&"<br>"
response.Write"詳細地址:"&address&"<br>"
response.Write"郵政編碼:"&zip&"<br>"
response.Write"聯系電話:"&phone&"<br>"
%></td>
</tr>
</table>
<p>
<input type="submit" name="button" id="button" value="https://bbs.csdn.net/topics/確認訂購" />
<a href="https://bbs.csdn.net/topics/orders4.asp"> <input type="button" name="button2" id="button2" value="https://bbs.csdn.net/topics/取消訂購" /></a>
</p>
<p> </p>
<p> </p>
</form>
<!--#include file="foot.inc"-->
</body>
</html>
<%
rs.Close()
Set rs = Nothing
%>
orders1.asp:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/conn.asp" -->
<%
CartID=session("CartID")
if CartID="" then CartID=0
set conn=server.CreateObject("adodb.connection")
conn.open MM_conn_STRING
set rsitem=server.CreateObject("adodb.recordset")
sql="select * from CartsItems where CartID="&CartID
rsitem.open sql,conn,0,1
if rsitem.eof then
rsitem.close
set conn=nothing%>
<hr><center>對不起,您還沒有購買任何商品,不能結賬。<br>
請單擊<a href="https://bbs.csdn.net/topics/products.asp">這里</a>繼續購物。</center>
<%
response.End
end if
rsitem.close
set conn=nothing
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>填寫送貨資訊</title>
<style type="text/css">
p {
text-align: center;
}
</style>
</head>
<body bgcolor="#bbddff">
<p><strong><em><font color="#800080" size="3" face="華文行楷">感謝您在網路商城購物!</font></em></strong></p>
<p><strong><font color="#000080" size="3" face="華文楷體">為了確保您的商品能夠及時送達,請準確填寫以下內容。</font></strong></p>
<form id="form1" name="form1" method="post" action="orders2.asp">
<table width="70%" border="1" align="center">
<tr>
<td width="22%" height="30" align="right">真實姓名:</td>
<td width="78%" align="left"><input name="name1" type="text" id="textfield" size="20" />
<font color="#FF0000">**</font></td>
</tr>
<tr>
<td width="22%" height="30" align="right">電子郵件:</td>
<td width="78%" align="left"><input name="email" type="text" id="textfield2" size="29" />
<font color="#FF0000">**</font></td>
</tr>
<tr>
<td width="22%" height="30" align="right">所在省份:</td>
<td width="78%" align="left"><input name="province" type="text" id="textfield3" size="20" />
<font color="#FF0000">**</font></td>
</tr>
<tr>
<td width="22%" height="30" align="right">所在城市:</td>
<td width="78%" align="left"><input name="city" type="text" id="textfield4" size="20" />
<font color="#FF0000">**</font></td>
</tr>
<tr>
<td width="22%" height="30" align="right">詳細地址:</td>
<td width="78%" align="left"><input name="address" type="text" id="textfield5" size="43" />
<font color="#FF0000">**</font></td>
</tr>
<tr>
<td width="22%" height="30" align="right">郵政編碼:</td>
<td width="78%" align="left"><input name="zip" type="text" id="textfield6" size="12" />
<font color="#FF0000">**</font></td>
</tr>
<tr>
<td width="22%" height="30" align="right">聯系電話:</td>
<td width="78%" align="left"><input name="phone" type="text" id="textfield7" size="20" />
<font color="#FF0000">** </font></td>
</tr>
</table>
<p>
<input type="submit" name="button" id="button" value="https://bbs.csdn.net/topics/提交" />
<input type="reset" name="button2" id="button2" value="https://bbs.csdn.net/topics/全部重填" />
</p>
<p>(注:有<font color="#FF0000">**</font>標記的專案必須填寫!)</p>
</form>
</body>
</html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/20063.html
標籤:網絡編程
上一篇:需求:
