Simple login system written by ASP

Source: Internet
Author: User
Tags add filter object empty end modify set set access database

Registration information modification Landing three parts. Access database Local machine test basic normal form required to use JS in the HTM page limit on the ASP page there is no tube.

  1. Registration

<%
' Get the user to fill in the account password
Unamethis=request ("UName")
Upwsthis=request ("UPWS")
Upws2this=request ("UPws2")
' Establish a database connection
Set Conobject=server.createobject ("Adodb.connection")
Conobject.open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("/data/webjxbbs.mdb")
' Set up the data set filter condition is the account number equals user fill in the account
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open "SELECT * from Tbuser WHERE uname= '" & Replace (Unamethis, "'", "" ") &" ", conobject,1,3
' Determine if the data set established above is empty if it is not indicated that the user in the database is not allowed to register the same account to register the failure page
If not Rs. EOF Or not Rs. BOF Then
Response.Redirect "Regfail.htm"
Response.End
End If
' Call the AddNew method to add a new user some are optional entries to determine their value is not NULL to add
Rs.addnew
RS ("UName") =unamethis
RS ("UPWS") =upwsthis
RS ("UPws2") =upws2this
If Request ("Uemail") <> "then
RS ("Uemail") =request ("Uemail")
End If
If Request ("UQQ") <> "then
RS ("Uqq") =request ("Uqq")
End If
If Request ("Uwebsite") <> "then
RS ("Uwebsite") =request ("Uwebsite")
End If
If Request ("Uintroduce") <> "then
RS ("Uintroduce") =request ("Uintroduce")
End If
' Call Update
Rs.update
Rs.close
Conobject.close
' Create a Session object
Session ("username") =unamethis
' Go to Success page
Response.Redirect "Userinfo.asp"
%>

  2. Success Page display

<%
' Fetch Session Object value
Unamethis=session ("username")
' Establish a data connection
Set Conobject=server.createobject ("Adodb.connection")
Conobject.open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("/data/webjxbbs.mdb")
' Set up the data collection filter condition is the account number equals the Session object value
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open "SELECT * from Tbuser WHERE uname= '" & Replace (Unamethis, "'", "" ") &" ", conobject,1,3
%>

3. Information modification

<%
' Get the password to support the change
Upwsthis=request ("UPWS")
Upws2this=request ("UPws2")
' Get the Session object value
Unamethis=session ("username")
' Establish a data connection to set up a data collection filter condition is the account equals session value
Set Conobject=server.createobject ("Adodb.connection")
Conobject.open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("/data/webjxbbs.mdb")
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open "SELECT * from Tbuser WHERE uname= '" & Replace (Unamethis, "'", "" ") &" ", conobject,1,3
' Call the Update method to modify a user project non-mandatory items are not NULL modified draft
RS ("UPWS") =upwsthis
RS ("UPws2") =upws2this
If Request ("Uemail") <> "then
RS ("Uemail") =request ("Uemail")
End If
If Request ("UQQ") <> "then
RS ("Uqq") =request ("Uqq")
End If
If Request ("Uwebsite") <> "then
RS ("Uwebsite") =request ("Uwebsite")
End If
If Request ("Uintroduce") <> "then
RS ("Uintroduce") =request ("Uintroduce")
End If
Rs.update
Rs.close
Conobject.close
' Turn to modify Success page '
Response.Redirect "Userinfo.asp"
%>

  4. Landing

<%
' Get the account number and password that the user fills in
Unamethis=request ("UName")
Upwsthis=request ("UPWS")
' Connect to the database
Set Conobject=server.createobject ("Adodb.connection")
Conobject.open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("/data/webjxbbs.mdb")
' Set up the data set filter condition is the account password and user fill in the same and replace function to prevent landing holes
Set Rs=server.createobject ("Adodb.recordset")
Rs.Open "SELECT * from Tbuser WHERE uname= '" & Replace (Unamethis, "'", "'") & "' and Upws= '" & Replace (Upwsthis, "'", "" "&" ", conobject,1,3
' Determine if the data set set up above is empty if the database has this user set up a session object to go to the correct page if the user does not go to the login failure page in the database
If not Rs. EOF Or not Rs. BOF Then
Session ("username") =unamethis
Response.Redirect ". /bbs/catalog.asp "
Response.End
End If
Response.Redirect "Loginfail.htm"
Response.End
%>



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.