shoplogin.asp
来自「ASP+SQL Server动态网站开发从基础到实践教程」· ASP 代码 · 共 88 行
ASP
88 行
<!--#include file="shop$db.asp"-->
<%
'*******************************************************
' allows user to login if they are an existing customer
' lastname and e-mail address is used as the keys
'*******************************************************
dim dbc
Session("CurrentUrl")="shoplogin.asp"
AdLogin
'
Sub AdLogin()
sAction=Request.form("Action")
If sAction = "" Then
ShopPageHeader
GetCustomerSessionData()
DisplayLoginForm()
ShopPageTrailer
Else
ValidateLoginData()
If Serror ="" then
RetrieveLoginData
end if
if sError = "" Then
UpdateCustomerSessionData
response.redirect Session("followonurl")
else
ShopPageHeader
DisplayLoginForm
ShopPageTrailer
end if
end if
end Sub
Sub DisplayLoginForm()
Dim sRowColor
sRowColor="#C4CEE5"
Response.Write("<blockquote>")
Response.Write("请输入email地址和姓名来确认身份<p>")
response.write ("<p><font size=2><a href=shopcustomer.asp?new=yes>新用户登录</a></font></p>")
if sError<> "" then
response.write "<b>" & SError & "</b>"
Serror=""
end if
Response.Write("<font color=red>" & sError & "</font><p>")
Response.Write("<form name=form1 method=Post action=" & Session("currenturl") & ">")
Response.Write("<table cellpadding=2 cellspacing=2>")
Response.Write("<tr bgcolor=" & sRowColor &"><td>Lastname:</td><td><input size=50 name=strLastname value=" & Chr(34) & strLastname & Chr(34) & "></td></tr>")
Response.Write("<tr bgcolor=" & sRowColor &"><td>Email:</td><td><input size=50 name=strEmail value=" & Chr(34) & strEmail & Chr(34) & "></td></tr>")
Response.Write("</table><p>")
Response.Write("<input type=submit name=action value=Continue>")
Response.Write("</form>")
Response.Write("</blockquote>")
End Sub
Sub ValidateLoginData()
strLastname = Request.Form("strLastname")
strEmail = Request.Form("strEmail")
If strLastname = "" Then
sError = sError & "必须输入姓名<br>"
End If
If strEmail = "" Then
sError = sError & "必须输入email地址<br>"
End If
end sub
Sub RetrieveLogindata
LocateCustomer Request.form("strLastName"), Request.form("strEmail")
If strCustomerID <>"" then
LngLoginCount=lngLoginCount+1
UpdateCustomerSessionData
Else
SError = SError & " 姓名或者email地址输入错误"
end if
ShopCloseDatabase dbc
set rs=nothing
end sub
Sub UpdateLoginData
Dim dbc
ShopOpenDatabase dbc
'response.write "Login count" & lngLoginCount
sql = "update customers set "
sql = sql & "LoginCount=" & lngLoginCount
sql = sql & ",LastLogindate='" & date() & "'"
Sql = sql & " WHERE LastName='" & strLastName & "' AND Email='" & strEmail & "'"
'response.write sql
dbc.execute(sql)
ShopCloseDatabase dbc
end sub
%>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?