1. 程式人生 > >簡單網上購物系統的實現

簡單網上購物系統的實現

頁面檔案: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
%>