Tutorials to .com

Tutorials to .com » Asp » Skills » With ASP to achieve a true sign-up page

With ASP to achieve a true sign-up page

Print View , by: iSee ,Total views: 54 ,Word Count: 1341 ,Date: Wed, 26 Aug 2009 Time: 9:59 PM

Beach Boys

(A), set the registration page looks like:

In this example, involves five pages, of which three are general htm file, the other two is the asp file, where the tool is making use of FrontPage 98, but most of the asp code that still have to input their own:

1, setting the already registered users to enter the appearance of: here set the two text boxes, a super-link and two buttons. Two text boxes were used to enter the account number (txtNum) and password (txtPasswd), hyperlinks (New) Link to the new user registration page, two buttons are used to submit and clear, and is used to remove the button (cmdReset ) direct selection for the Reset type, but used to submit button (cmdTijiao) does not want to select for the Submit type, choose the Normal type, which is this button in order to add the onClick event code, and to determine the legality of the user's input !

2, setting a new user login page appearance: usually have to enter a new user account, password, name, and related some of the information, here we have five text boxes, a drop-down list box and two buttons, 5 text boxes on the difference is to allow the user to enter name, email, account number, password, set password. However, only be used to enter the account number, password and Confirm password text boxes with the name, namely, txtNum, txtPasswd and txtConfirm. The name of the submit button cmdTijiao

3, this step of course is set after successful registration, users enter the page, and which it is decided by the bar:)

(B), add the code:

1, first of all the already registered users to add the page code, which deal primarily with cmdTijiao_onClick events and user input to determine whether the legal requirements in this case account must be a number, the password can not be empty, the code is as follows, where frmRes this page in the name of the window, the window's Action point 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 account number and password the corresponding content, the account must be a number!"
else frmRes.submit
end if
end sub
2, add a new user landing page code, which is used to dealing with cmdTijiao_onClick events, requires the user to enter the account must be a number, passwords, and determine the password must be the same, this page of the window of Action points to http://your/NewRes . asp, code is as follows:

sub cmdTijiao_onClick ()
if Not IsNumeric (frmNew.txtNum.value) or frmNew.txtPasswd.value <> frmNew.txtConfirm.value then
Alert "entered incorrectly, please re-enter!"
else frmNew.submit
end if
end sub
3, create ResJudge.asp file, the asp file to open the main function is to store registration information in the database to find whether there is with the front page of the account number and password to submit the record to match, if that is successfully registered, but can also in the database Find out the relevant information to the user, the user should be allowed to enter into the page he had hoped, if not then the registration fails, the entire code is as follows:

<html> <head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<meta name="GENERATOR" content="Microsoft Fronpage 3.0">
<titile> register to determine </ title> </ head>
<body> <%
Num = Request.form ( "txtNum") "put in front of the window to send to the contents of the two strings assigned to Num and Passwd.
Passwd = Request.form ( "txtPasswd")
dbname = "Driver = (Microsoft access Driver (*. mdb)); DBQ =" & Server.MapPath ( "\ ")"&" \ ResDb \ Res.mdb;" "dbname is open the database to use the
set Cres = Server.CreateObject ( "ADODB.Connection") "The following is the use of Connection and Recordset objects, like pairs of linking databases and search code.
set res = Server.CreateObject ( "ADODB.Recordset")
Cres.open dbname
res.ActiveConnection = Cres
res.source = "Select * from res where Account = '" & Num & "' and password = '" & Passwd &'";"
if res.BOF then "If the search result is empty, then the registration statement is not correct, so the page displays the following text /
%> <p> registration is incorrect, please return to the registration page to re-register! </ p>
else "Otherwise, it shows successful registration, you can enter the browser page!
% "
<!--# Include virtual = "/ success.htm" -> "here, using Server Side Include the method to allow browsing of the pages contained in this file inside!
<% Res.Close "shut down just open the database.
end if%>
</ body> </ html>
4, create NewRes.asp this document, the main functions of the new user's login information into the database, the code is as follows:

<html> <head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<meta name="GENERATOR" content="Microsoft frontpage 3.0">
<title> entered into the database </ title> </ head>
<body> <!--# Include virtual = "/ adovbs.inc"> "This file is included in. adovbs.inc is to define database objects ADO constants document.
Num = Request.form ( "txtNum") "put in front of home delivery over the contents of the two variables assigned to Num and Passwd.
Passwd = Request.form ( "txtPasswd")
Set res = Server.CreateObject ( "ADODB.Recordset") "to open the database.
dbname = "Driver = (Microsoft Access Driver (*. mdb)); DBQ =" & ServerMapPath ( "\") & "\ ResDb \ Res.mdb;"
sql = "select * from res"
res.open sql, dbName, adOpenKeyset, adLockOptimistic
res.AddNew "Add new record
res (1) = Num "res (1) on behalf of the database in the second field, store the user's account.
res (2) = Passwd "res (2) on behalf of the third field in the database, storing the user's password.
res.Update "update the database /
<p> <b> <font face=_gb2312 size=5> your account number and password has been successfully registered, you can now <a href="http://your/index.htm"> access </ a> a! </ font> </ p>
</ body> </ html>

This article from the Beach Boys organize production, you may be reproduced, but please be sure to indicate its source and maintain its integrity, thank you!

ASP skills Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.