|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
Note the use of many of the things youve seen so far in this chapter:
Users entering a valid ID into the initial form will now see their current contact information displayed in a HTML form that they can update if required. Then, after they click the Continue button, the ASP promo2.asp is launched to process the submitted form data. promo2.asp, shown in Listing 33.9 builds the SQL statement to update the database with the submitted information and then presents a thank-you message to the user (see Figure 33.3). Listing 33.9 Code Listing for promo2.asp <% dim ID dim FirstName dim LastName dim Title dim Company dim Address1 dim Address2 dim City dim State dim Zip dim Phone dim Fax dim Email dim Decide dim Amount FirstName= request.form(FirstName) LastName = request.form(LastName) Title = request.form(Title) Company = request.form(Company) Address1 = request.form(Address1) Address2 = request.form(Address2) City = request.form(City) State = request.form(State) Zip = request.form(Zip) Phone = request.form(Phone) Fax = request.form(Fax) Email = request.form(Email) Decide = request.form(Decide) Amount = request.form(Amount) ID = request.form(ID) Build SQL statement SQL=UPDATE Clients SQL= SQL + SET FirstName= & FirstName & ,LastName= & LastName SQL= SQL + ,Title= & Title & ,Company= & Company & , SQL= SQL + Address1= & Address1 & ,Address2= & Address2 &, SQL= SQL + City= & City & ,State= & State & , SQL= SQL + Zip= & Zip & ,Phone= & Phone & , SQL= SQL + Fax= & Fax & ,Email= & Email & , SQL= SQL + Decide= & Decide & , SQL= SQL + Amount= & Amount SQL= SQL + WHERE ClientID= & ID Execute Query - execute the update Set dRS= dConn.Execute(SQL) Clean Up RecordSets for Better memory management dRS.Close Set dRS=Nothing %> <HTML> <HEAD> <TITLE>Information Updated!</TITLE> </HEAD> <BODY BGCOLOR=WHITE> <H2>Thank you, <%=FirstName%></H2> Thanks for participating in our survey. We look forward to supporting you in the future. </BODY> </HTML>
Again, the ASP file uses the Request object and the ADO Component to take the users input, compose a SQL statement that will update the users record, and then perform the update. Now that you have seen some of the basics of VBScript and ASP development, it would not be hard to extend this sample application to include greater functionality, such as assigning a client ID number to someone who does not have one or doing some basic error-checking. Additionally, you should be able to easily adapt the approaches used in this example to build other ASP applications for your Web site. For more information on ASP development, consult the ASP developer resource site found at http://www.activeserverpages.com/.
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |