Asp+access User Login code, AN.MDB database name
FD Table Name
Y_username user name segment, y_password password field.
Loginnew.asp Web page
<%
Dim Username,password
Username=request.form ("username")
Password=request.form ("password")
Set Rs=server.createobject ("Adodb.recordset")
conn = "dbq=" + Server.MapPath ("Huiyuan.mdb") + ";D efaultdir=;
Driver={microsoft Access DRIVER (*.mdb)};
Sql= "SELECT * from pUser213 where y_username= '" &username& ""
Rs.Open sql,conn,1,1
If Rs.eof Then
Response.Write "<script>alert (' Login failed '); History.back ();</script>"
Response.End
Else
If RS ("Y_password") <>password Then
Response.Write "<script>alert (' Login failed '); History.back ();</script>"
Response.End
End If
Session ("admin") =username
Response.Write "<script>alert" (' Login Success '); location.href= ' index.asp ' </script> '
End If
%>
Look at the HTML code again.
Login.htm page
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<title> Login </title>
<body>
<p> </p>
<form name= "Form1" method= "Post" action= "loginnew.asp" >
<table width= "border=" 1 "align=" center "cellpadding=" 0 "cellspacing=" 0 ">
<tr>
<TD colspan= "2" ><div align= "center" > Login </div></td>
</tr>
<tr>
<TD width= "><div" align= "center" > Username </div></td>
<TD width= "137" valign= "Top" ><input "name=" username "text"
Id= "username" size= "></td>"
</tr>
<tr>
<td><div align= "center" > Password </div></td>
<TD valign= "Top" ><input name= "password" type= "password"
id= "Password" size= "></td>"
</tr>
<tr>
<TD colspan= "2" ><div align= "center" >
<input type= "Submit" name= "Submission" value= "submitted" >
</div></td>
</tr>
</table>
</form>
</body>