Encrypt your site with ASP

Source: Internet
Author: User
A reader who is learning to build a Web site may be worrying about the security of the site; maybe you're building a non-publicity website, and only system users can access your site. If you are compiling an ASP page, you can easily achieve this by using this article.
First, you need to make a login page, add a form to the HTML, and set it as a spontaneous delivery page.
〈form Name=″login″action=″default. asp″method=″post″target=″-top″〉
Action is followed by the URL on this page so that even if the user logs in incorrectly, you will be prompted on this page without having to return to the previous page. Add in Form
〈input name=″uid″size=″10″maxlength=″10″style=″height:21px; width:101px″〉
〈input name=″pwd″type=″password″size=″10″maxlength=″10″〉
After you complete the HTML, add the program code to the top of the page as follows:
〈%′send customer direct to main page if already logged in
If not IsEmpty (sessions (″cust-id″)) and Len (Session (″cust-id″)) 〉0 then Response.Redirect (″NAVIGATION/DASHBRD. Asp″)
To add your real homepage URL here
End If
′set Flags
Blogin = False
Berror = False
′check Blank Entries
If IsEmpty (Request ″uid″) or Len (request ″uid″) = 0 or IsEmpty (Request (″pwd″)) or Len (Request (″pwd″)) = 0 Then
′need to log in
Blogin = True
Else
′check user credentials against DB
... to verify that the user in your database saved password table
Add the connection database code here
The SQL is as follows ″select * from customer where cust-id=′″& request (″uid″) &″′and′cust-pwd=′″& request (″pwd″) &″′″
The ″uid″ and request (″pwd″) is the text of the user name and password in the form in HTML on this page
Gbfound = False
If not rscust.bof and not rscust.eof then
Gbfound = True
End If
If Gbfound Then
′record useful Customer info in session variables
Session (″cust-id″) = Rscust.fields (″cust-id″)
This is the user name in the database
Session (″cust-pwd″) = Rscust.fields (″cust-pwd″) This is the user password in the database
Session (″power″) = Rscust.fields (″power″) This is the user right in the database [optional]
′update Last login time [optional]

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.