如何對這些用戶進行驗證

  如何對這些用戶進行驗證

       <%     dim     txtName,txtPsw     txtName=trim(request.Form("textfield"))     '表單域中輸入的帳號     txtPsw=trim(request.Form("textfield2"))     '表單域中輸入的密碼         if   txtName=""   or   txtPsw=""   then     response.Write   "用戶名或密碼不能爲空!"       response.End()     end   if         dim   objConn,objRs,strSQL                 Set   objConn   =   Server.CreateObject("ADODB.Connection")                                                                 objConn.ConnectionString   =   "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source="   &   Server.MapPath("你的數據庫名.mdb")                                           objConn.Open     strSQL   =   "select   *   Login   where   Account='"   &   txtName   &   "'"       'Account   是數據庫中的帳號字段             Set   objRs   =   Server.CreateObject("ADODB.Recordset")               objRs.Open   strSQL,objConn,   1,1     if   objRs.eof   then     objRs.close     set   objRs   =   nothing     objConn.close     set   objConn   =   nothing     response.Write   "此用戶不存在,請確定用戶名!"       response.End()     end   if     if   objRs("Password")<>txtPsw   then           'Password   是數據庫中的密碼字段     objRs.close     set   objRs   =   nothing     objConn.close     set   objConn   =   nothing     response.Write   "密碼不正確,請確認密碼!"       response.End()     end   if     dim   rank     rank   =   objRs("rank")             'rank   是數據庫中的權限字段   ,如:1是管理員,2是會員,3是普通用戶           objRs.close     set   objRs   =   nothing     objConn.close     set   objConn   =   nothing     if   rank=1   then     response.Redirect("webs/index1.asp")     elseif   rank=2   then     response.Redirect("webs/index2.asp")     elseif   rank=3   then     response.Redirect("webs/index3.asp")     end   if         %>

發佈了5 篇原創文章 · 獲贊 5 · 訪問量 5萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章