Implementation of a real registration page with ASP

Source: Internet
Author: User
Tags generator microsoft frontpage
(a), set the appearance of the registration page:

In this example involved five pages, of which three is a general HTM file, the other two is an ASP file, where the use of the tool is frontpage98, but most of the ASP code or to enter their own:

1, set the original registered user to enter the appearance: here set up two text boxes, a hyperlink and two buttons. Two text boxes are used to enter account number (Txtnum) and password (txtpasswd), hyperlink (new) Link to the user to register the page, two buttons are used to submit and clear, to clear the button (Cmdreset) directly selected as the reset type, However, the button to submit (Cmdtijiao) does not have to be selected as the submit type, but the normal type is chosen to add code to the OnClick event of the button and to determine if the user's input is legitimate!

2, set the new user landing page appearance: The general is to new user input account, password, name, and related information, here we have five text boxes, a Drop-down list box and two buttons, five text boxes are to let users enter the name, email, account number, password, determine the password. But only the text boxes that are used to enter account numbers, passwords, and password determination are named TXTNUM,TXTPASSWD and Txtconfirm respectively. The name of the Submit button is Cmdtijiao

3, this step of course is set up after the success of the user to enter the page, which is decided by everyone:

(ii), add program code:

1, first add the original already registered user page code, it is mainly to handle Cmdtijiao_onclick events, and to determine whether the user's input is legitimate, in this case, the account must be a number, the password can not be null, the code is as follows, where Frmres is the name of the window in this page, The action of the window points to http://your/ResJudge.asp

Sub Cmdtijiao_onclick ()
If frmres.txtnum.value= "" or frmres.txtpasswd.value= "" or (not IsNumeric (frmRes.txtNum.value)) Then
Alert "Please enter the corresponding content in the account number and the password, the account number must be digital!" "
else Frmres.submit
End If
End Sub
2, add a new user login page code, which is used to deal with Cmdtijiao_onclick events, require the user input account number must be, password and determine the password must be the same, the window of this page action point to http://your/NewRes.asp, the code is as follows:

Sub Cmdtijiao_onclick ()
If not IsNumeric (frmNew.txtNum.value) or Frmnew.txtpasswd.value<>frmnew.txtconfirm.value Then
Alert "Input is not correct, please re-enter!" "
else Frmnew.submit
End If
End Sub
3, create resjudge.asp file, the main function of this ASP file is to open the database that stores registration information, find out if there is a record that matches the account number and password that you submitted on the previous page, and if so, the registration is successful, and you can also find information about the user in the database, and you should allow this user to enter what he wants. The page, if not the registration failed, the entire code is as follows:

<meta http-equiv= "Content-type" content= "text/html;charset=gb2312" >
<meta name= "generator" content= "Microsoft fronpage 3.0" >
<titile> Registration Judgment </title><body><%
Num=request.form ("Txtnum") assigns the contents of the front window to num and passwd two strings.
Passwd=request.form ("txtpasswd")
Dbname= "Driver={microsoft Access Driver (*.mdb)};D bq=" &server.mappath ("\") "&" \resdb\res.mdb; "" DBName is used to open the database.
Set Cres=server.createobject ("ADODB. Connection ")" is the following code that uses Connection to join the database and find the Recordset object.
Set Res=server.createobject ("ADODB. Recordset ")
Cres.open dbname
Res. Activeconnection=cres
Res.source= "Select*from res where account = '" &Num& "' and password = ' &Passwd& '";
Res.open
If Res. BOF then "If the lookup result is empty, the registration is incorrect, so the following text is displayed on the page
%><p> registration is not correct, please return to the registration page to register again! </p>
<%
Else "Otherwise the registration is successful, you can enter the browsing page!"
%>
<!--#Include virtual= "/success.htm"--> "The server Side include method is used to include pages that allow browsing in this file!
<% Res. Close "Closes the database you just opened.
End If%>
</body>
4, create newres.asp file, the main function of this file is to put the new user login information into the database, the code is as follows:

<meta http-equiv= "Content-type" content= "text/html;charset=gb2312" >
<meta name= "generator" content= "Microsoft FrontPage 3.0" >
<title> Input Database </title><body><!--#Include virtual= "/adovbs.inc" > "This included file Adovbs.inc is a file that defines the database object ADO constants.
<%
Num=request.form ("Txtnum") assigns the contents of the previous home page to num and passwd two variables.
Passwd=request.form ("txtpasswd")
Set res=server.createobject ("ADODB. Recordset ")" to open the database.
Dbname= "Driver={microsoft Access Driver (*.mdb)};D bq=" &servermappath ("\") & "\resdb\res.mdb;"
Sql= "Select*from res"
Res.open sql,dbname,adopenkeyset,adlockoptimistic
Res. AddNew "Add new record
Res (1) =num res (1) Represents the second field in the database, and the user's account number is stored.
Res (2) =passwd res (2) represents the third field in the database that stores the user's password.
Res. Update updates the database/
Res. Close%>
<p><b><font face= italics _gb2312 size=5> your account number and password have been registered successfully, you can now <a href= "http://your/index.htm" > enter </a>! </font></p>
</body>

This article by the Beach Kid Finishing production, you can reprint, but please be sure to indicate its source and maintain its integrity, thank you!



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.