我做的很简单,就是一个登陆界面,代码如下: Login.asp: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>登陆</title> <script language="javascript"> <!-- function validatalogin(){ var strUserName = document.frmlogin.txtUserName.value; var strPassword = document.frmlogin.txtPassword.value; var primeInUserName = document.frmlogin.txtUserName.value.indexOf("'"); var primeInPassword = document.frmlogin.txtPassword.value.indexOf("'"); if (strUserName==""){ alert("请输入用户名"); return false; } if (strpassword==""){ alert("请输入密码"); return false; } if (primeInUserNmae !=-1){ alert("用户名中不能包含撇号!"); return false; } if (primeInPassword !=-1){ alert("密码中不能包含撇号!"); return false; } } --> </script> </head> <style type="text/css"> <!-- .style2 { font-size: 18px; color: #006666; } .style3 {color: #006666} --> </style> <body> <form name="frmLogin" method="post" action="verifyID.asp" onSubmit="javaScript.return validateLogin();"> <table width="300" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <th align="center" valign="middle" scope="col"><p> </p> <p> </p> <p><span class="style2">登陆界面</span> </p> <p><span class="style3">用户名:</span> <input name="txtUserName" type="text" id="txtUserName" size="20" maxlength="20"> </p> <p><span class="style3">密 码:</span> <input name="txtPassword" type="password" id="txtPassword" size="20" maxlength="20"> </p> <p> <input type="button" name="Submit" value="提交"> <input name="reset" type="reset" id="reset" value="重置"> </p> <p> </p></th> </tr> </table> </form> </body> </html> verifyID.asp: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>登陆</title> </head> <body> <div align=center> <% dim strUserName dim strPassword dim conn dim rs dim sql
strUserName=request.form("txtUserName") strpassword=request.form("txtPassword") if strUserName="" or strPassword="" then response.redirect"Login.asp" end if if (instr("'",strUserName,1)) or (instr("'",strPassword,1)) then response.redirect"Login.asp" end if
set conn=server.CreateObject("ADODB.Connection") conn.open"Driver={SQL Server};" & "server=zbt;" & "Database=LearnAsp;" & "Uid=sa;Pwd=123" set rs=server.CreateObject("ADODB.recordset") sql=select * from UserInfo where (User_Name='"&strUserName&"'"&" and Password='"&strPassword&"')' set rs=conn.Execute(sql) if rs.eof=fase then session("UserName")=strUserName response.write"登陆成功" else response.write"登陆失败" end if set rs=nothing conn.close set conn=nothing %> </div> </body> </html> 拜托大家给我看看。