home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next



FIGURE 33.2  If a user’s ID number is found in the database, you present him with his information as it currently exists and invite him to update it.

Note the use of many of the things you’ve seen so far in this chapter:

  VBScript for validation of the form input and general control of the processing through if-then-else type statements
  Use of the Request object to get the form data submitted by the user
  Use of the ADO component to initiate a query against the database
  Referencing the ADO object to get the values of the fields returned in the query

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>


Figure 33.3  A second ASP takes care of updating the database and presenting a closure message to the user.

Again, the ASP file uses the Request object and the ADO Component to take the user’s input, compose a SQL statement that will update the user’s 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/.


Previous Table of Contents Next


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.