People who are new to ASP have not been knowing the session very much. My Cai bird is here to talk about the simple use of session when making a simple background. Wulin.com recommends that you use session to make a management login page in this ASP programming page in this ASP programming page. The instance code, there is also a tutorial on the log -in page of the ASP programming session. I hope you can like and learn what to enhance your knowledge and skills. The following is a detailed reading:
One: login.htm
I won't say much on this page. Add the nickname of the administrator to the text box username
Write the password to give the text box userpass and add a submission and press twist. Note: The action of the form is chklogin.asp
Two: chklogin.asp
<!-#Include file = conn.asp->
<%set rs = server.createObject (adodb.recordset)
SQL = Select * From Admin where username = '& request.form (username) &'
'Among them, admin is the table name of the store account and password of the storage administrator
RS.Oopen SQL, CON, 1,1
%>
<%if rs.eof then
response.write does not have this administrator
else
%>
<%
username = trim (request.form (username))
password = request.form (password)
%>
<%if password = RS (userpass) then
session (admin) = ERCIFANG
response.redirect (manage.asp)
else
response.write This page is a special page for administrators
end if
%>
<%End IF%>
Look at the red text, so that a session is added to the administrator
Set in the first line in manage.asp
<%if session (admin) = ERCIFANG THEN
Nympho
else
response.write can only enter this page
End If%>
In this way, other people cannot manage this site when they visit Manage.asp directly.
The code of login.htm is given below:
<html>
<head>
<meta http-equiv = content-type content = text/html; charset = gb2312>
<Title> Management Login </Title>
<Style Type = Text/CSS>
.fengge {font-size: 12px}
</style>
</head>
<body>
<FORM NAME = FORM1 Method = Post Action = chklogin.asp>
<Table width = 400 border = 1 align = center class = fengge>
<tr>
<td width = 129> </td>
<td width = 255> </td>
</tr>
<tr>
<td> <div Align = Right> Administrator name: </div> </td>
<td> <input name = username type = text id = username> </td>
</tr>
<tr>
<td> <div Align = Right> Management Password: </div> </td>
<td> <input name = password type = password id = password> </td>
</tr>
<tr>
<td> <div Align = Right> </div> </td>
<td> <input type = submit name = submit value = Submit>
<input type = reset name = submit value = reset>
</td>
</tr>
<tr>
<td colorpan = 2> <div align = right> </div> </td>
</tr>
</table>
</form>
</body>
</html>
This page website: http://www.vevb.com/biancheng/2018091514119.shtml, if you help you welcome to collect or reprint the URL, please visit http://www.vevb.com again!