How do I authorize a user? _ Programming 10000 Q

Source: Internet
Author: User

Authenticate.asp
<%
Dim URL
URL = Request.QueryString

'GetUrl.
%>

<body>
<form method=post action= "/validate.asp" >
<input type=hidden name= "URL" value= "<%=URL%>" >
'url Save to a hidden variable   username :
  <input Type=text name= "txtname"
  password Span lang= "en-us":
  <input type=password name= "Txtpassword"

  <input type=submit>
</form>
</body>     validate.asp file gets the information passed to it, reads the username and password from the database to determine whether to authorize the user.

Validate.asp
<%
Dim strUserName, Strpassword
strUserName = Request.Form ("Txtname")
strpassword = Request.Form ("Txtpassword")
' read the user name and password from the form .


' establish a database connection ...

Dim strSQL
strSQL = "SELECT * from validusers WHERE UserName =" & _
strUserName & "and Password =" & _
Strpassword

' for SQL queries .

Dim RS
Set rs = Conn.execute (strSQL)

If Rs. EOF Then

' The user name is valid if the recordset is not empty .
Session ("bolauthenticated") = True

' set bolauthenticated to True.

Response.Redirect Request.Form ("URL")

' pass the user a URL that has come .
Else
Response.Redirect "/notvalidated.asp

',
End If
%>

[1]

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.