CSDN博客

img zhoujiping

简单网上购物系统的实现

发表于2004/9/25 15:14:00  2491人阅读

页面文件:login.asp
<!--#include file="conn.asp"-->
<!--#include file="webconfig.asp"-->
<form name="fkinfo" method="post" action="checkuserlogin.asp">
<input type="hidden" name="linkaddress" value="<%=request.servervariables("http_referer")%>">
<input name="imageField" type="image" src="images/login_bt_login.gif" width="45" height="19" border="0" onFocus="this.blur()">
<SCRIPT LANGUAGE="JavaScript">
<!--
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

function checkfk()
{
   if(checkspace(document.fkinfo.username.value)) {
 document.fkinfo.username.focus();
    alert("请填写用户名!");
 return false;
  }
   if(checkspace(document.fkinfo.userpassword.value)) {
 document.fkinfo.userpassword.focus();
    alert("请填写密码!");
 return false;
  }
}
//-->
</script>
检查用户登录页面:checkuserlogin.asp
<!--#include file="conn.asp"-->
<!--#include file="md5.asp"-->
<%dim username,userpassword,comeurl
username=replace(trim(request("username")),"'","")
userpassword=md5(replace(trim(request("userpassword")),"'",""))
if username="" or userpassword="" then
response.write "<script LANGUAGE='javascript'>alert('对不起!您的用户名或密码有误!');history.go(-1);</script>"
response.end
end if
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from [user] where username='"&username&"' and userpassword='"&userpassword&"' " ,conn,1,3
if not(rs.bof and rs.eof) then
if userpassword=rs("userpassword") then
response.Cookies("songxf")("username")=trim(request("username"))
response.Cookies("songxf")("reglx")=rs("reglx")
response.Cookies("songxf")("jifen")=rs("jifen")
response.Cookies("songxf")("jiaoyijine")=rs("jiaoyijine")

 

 Response.Cookies("aspsky")("username") = rs("username")
 Response.Cookies("aspsky")("password") = rs("userpassword")
 Response.Cookies("aspsky")("userclass") = rs("userclass")
 Response.Cookies("aspsky")("userid") =rs("userid")
 Response.Cookies("aspsky")("userhidden") = 2
 Response.Cookies("aspsky").path="/shop/shop/bbs/"
  Response.Cookies("aspsky")("usercookies") = 1
 Response.Cookies("aspsky").Expires=Date+1

 

rs("lastlogin")=now()
rs("logins")=rs("logins")+1
rs("userlastip")=Request.ServerVariables("REMOTE_ADDR")
rs.Update
rs.Close
set rs=nothing
username=trim(request("username"))
conn.execute("delete from shop_action where username='"&username&"' and zhuangtai=7")
conn.execute("delete from shop_action_jp where username='"&username&"' and zhuangtai=7")
if request("linkaddress")="" then
response.redirect request.servervariables("http_referer")
else
response.redirect request("linkaddress")
end if
else
response.write "<script LANGUAGE='javascript'>alert('对不起,您的用户名或密码有误!');history.go(-1);</script>"
end if
else
response.write "<script LANGUAGE='javascript'>alert('对不起!您的用户名或密码有误!');history.go(-1);</script>"
end if
'sub loginok()
'response.Write "<font size=2>欢迎您 <font color=red size=2>"&request.Cookies("bookshop")("username")&"</font>,两秒种后将自动跳转到相应页!</font>"
'response.redirect "index.asp"
'end sub
%>

阅读全文
0 0

相关文章推荐

img
取 消
img