How to authorize a user?

Source: Internet
Author: User

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

'ObtainURL.
%>

<Html>
<Body>
<Form method = post action = "/validate. asp">
<Input type = hidden name = "URL" VALUE = "<% = URL %>">
'SetURLSave to a hidden variable.
User Name:
<Input type = text name = "txtName">
 Password:
<Input type = password name = "txtPassword">

<Input type = SUBMIT>
</FORM>
</Body> ReuseValidate. aspFile, read the user name 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 username and password from the form.


'Establish Database Connection...

Dim strSQL
StrSQL = "select * from ValidUsers WHERE UserName = "&_
StrUserName & "AND Password = "&_
StrPassword

'ProceedSQLQuery.

Dim rs
Set rs = Conn. Execute (strSQL)

If rs. EOF Then

'IfRecordsetNot empty,The user name is valid..
Session ("bolAuthenticated") = True

'SetBolAuthenticatedSetTrue.

Response. Redirect Request. form ("URL ")

 'Pass the userURL.
Else
Response. Redirect "/notvalidated. asp

' Otherwise, the user is not authorized to access , Pass the user to an error prompt page .
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.