<%
'-------------------为防止出错我们定义username和password----------------
dim userID
dim password
'--------用request的form方法来接受login.asp页面传来的值,并付值给我们定义的userID和password
userID=request.form("userID")
password=request.form("password")
'---------判断传来的值是不是空值
if userID="" then
'用response的write的方法输出一个脚本
response.write"<script>alert('用户名不能为空')</script>"
response.end
end if
if password="" then
response.write"<script>alert('密码不能为空')</script>"
response.end
end if
'----------判断用户名和密码是不是正确,如果一样的输出"登陆成功"并把session的标志给这个用户,否则就输出"登陆失败"
set myconn=server.createobject("ADODB.Connection")
set adoRS=server.createobject("ADODB.Recordset")
myconn.open "Orderinfo"
sSQL="select ContactID,CustomerID from contact where ContactID=userID and CustomerID=password "
set adoRS=myconn.execute(sSQL)
if adoRS.bof and adoRs.eof then
response.write "无此用户或密码错误,请重新登录!"
else
session("ContactID")=ContactID
session("CustomerID")=CustomerID
response.redirect("login.asp")
end if
adoRS.close
set adoRS=nothing
end if
if userID=ContactID and password=CustomerID then
response.write"登陆成功"
response.redirect"detail.asp"
else
response.write"登陆失败"
response.redirect"login.asp"
response.write"<script>alert('登陆失败')</script>"
end if
myconn.close
set myconn=nothing
%>
<%
'-------------------为防止出错我们定义username和password----------------
dim userID
dim password
'--------用request的form方法来接受login.asp页面传来的值,并付值给我们定义的userID和password
userID=request.form("userID")
password=request.form("password")
'---------判断传来的值是不是空值
if userID="" then
'用response的write的方法输出一个脚本
response.write"<script>alert('用户名不能为空')</script>"
response.end
end if
if password="" then
response.write"<script>alert('密码不能为空')</script>"
response.end
end if
'----------判断用户名和密码是不是正确,如果一样的输出"登陆成功"并把session的标志给这个用户,否则就输出"登陆失败"
set myconn=server.createobject("ADODB.Connection")
set adoRS=server.createobject("ADODB.Recordset")
myconn.open "Orderinfo"
sSQL="select ContactID,CustomerID from contact where ContactID=userID and CustomerID=password "
set adoRS=myconn.execute(sSQL)
if adoRS.bof and adoRs.eof then
response.write "无此用户或密码错误,请重新登录!"
else
session("ContactID")=ContactID
session("CustomerID")=CustomerID
response.redirect("login.asp")
end if
adoRS.close
set adoRS=nothing
end if
if userID=ContactID and password=CustomerID then
response.write"登陆成功"
response.redirect"detail.asp"
else
response.write"登陆失败"
response.redirect"login.asp"
response.write"<script>alert('登陆失败')</script>"
end if
myconn.close
set myconn=nothing
%>