ASP user login, exit login function

Source: Internet
Author: User

<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>asp Tutorial User login, exit login function </title>

<body>
<form action= "Login.asp" method= "post" name= "LoginForm" id= "LoginForm" onsubmit= "return check ();" >
<table width= "border=" 0 "cellspacing=" 5 "cellpadding=" 0 ">
<tr>
<td><strong> username:</strong> <input type= "text" size= "" name= "username" >
<strong> password:</strong> <input name= "userpass" type= "password" id= "Userpass" size= "></td>"
</tr>
<tr>
<td> remain logged in:
<input name= "Issave" type= "Radio" value= "0" >
Do not save
<input name= "Issave" type= "Radio" value= "1" checked>
Keep the day
<input type= "Radio" name= "Issave" value= ">"
Keep it for one months.
<input type= "Submit" name= "submit" value= "Login" ></td>
</tr>
</form>
</body>


Login.asp

<%
On Error Resume Next
Set Conn=server.createobject ("Adodb.connection")
Conn.Open ConnStr
If Err Then
Response.Write "&issqlver&" Database Tutorial connection error, please check the connection string. <br><br> "&err.source&" ("&err.number&")
Set conn = Nothing
Err.Clear
Response.End
End If


Dim Expires,userpass
Username=request ("username")
USERPASS=MD5 (Request ("Userpass"), 16)
Expires=request ("Issave")
If username<> "test" then

Set Rs=server.createobject ("Adodb.recordset")
Rs.Open "SELECT * from Lg50_my_user where username= '" &username& "' and password= '" &userpass& "", Conn, 1,3
If rs.eof and Rs.bof then
Rs.close
Set rs=nothing
Response.Write ("<script language= page Special effects >alert (' Please enter the correct username and password '); this.location.href= ' login.htm ';</script> ")
Response.End
Else
Response.Cookies (Cookiesname) ("username") =username
if int (expires) >0 then Response.Cookies (cookiesname). expires = Date+expires
Response.Redirect ("index.asp")
End If

Else
Response.Cookies (Cookiesname) ("username") =username
Response.Redirect ("index.asp")
Response.End
End If
%>


Exit Login

<%
If Request ("out") = "BBS" then
   response.cookies (cookiesname) ("username") = ""    Response.Redirect "/www.111cn.net/login.asp?menu=out&bbs=bbs"
Else
  Response.Cookies (Cookiesname) ("username") = ""
  Response.Redirect ("login.htm")
End If
%>  /blockquote>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.