ASP Simple User Login code

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> Untitled Document </title>

<body>
<form id= "Form1" Name= "Form1" method= "Post" action= "" >
<label>
<input type= "text" name= "name" id= "TextField"/>
</label>
<p>
<label>
<input type= "text" name= "pwd" id= "Textfield2"/>
</label>
</p>
<p>
<label>
<input type= "Submit" name= "button" id= "button" value= "submitted"/>
</label>
</p>
</form>
</body>

<%
If Request.Form ("name") <> "then
Login ()
End If
function Login ()
Dim sql,username,userpwd,user
Username=html_encode (Request.Form ("name"))
Userpwd=html_encode (Request.Form ("pwd"))
User=request.form ("User")
If Len (username) <4 or len (username) >16 Then
Response.Write (' <script language= ' javascript tutorial ' >alert (' Sorry, username illegal! '); History.back ();</script> ")
Response.End
End If
If Len (userpwd) <4 or Len (userpwd) >16 Then
Response.Write (' <script language= ' JavaScript ' >alert (' Sorry, the password is illegal! '); History.back ();</script> ")
Response.End
End If
If CInt (user) <>session ("user") then
Response.Write (' <script language= ' JavaScript ' >alert (' Sorry, wrong captcha! '); History.back ();</script> ")
Response.End
End If
Sql= "SELECT * from Reg where username= '" &username& "' and password= '" &userpwd& "'"
Call Opensql ()
Sqlrs.open SQL,SQLCN
If not sqlrs.eof then
Session ("username") =username
Response.Redirect (".. /usermange.asp?user= "&username)
Else
Response.Write ("<script language= ' JavaScript ' >alert" Sorry, Login failed username does not exist, please try again!) '); History.back ();</script> ")
End If
End Function

' The first is to get the user's username and password, and then make a comparison of the data to judge, if it is not legal to query the database tutorial, if the validation of the rules to verify the database username and password verification, validation through the user name saved to the session, and then jump to the page we want to process.
%>

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.