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


Listing 33.7 Form to Prompt User for Promotion ID


<HTML>
<HEAD>
<TITLE>Your Company: Marketing Promotion</TITLE>
</HEAD>
<BODY BGCOLOR=”WHITE”>
<BLOCKQUOTE>
Please enter your ID number below and click the “Enter Promotion” button.<P>
<FORM ACTION=”promo1.asp” METHOD=”POST”>
<INPUT TYPE=”TEXT” NAME=”ID” SIZE=10><P>
<INPUT TYPE=”SUBMIT” VALUE=”Enter Promotion”>
</FORM>
</BODY>
</HTML>

Next you need to create the file promo1.asp that will use the ID number entered by the user to query your “promotion” data source and present the information found in a second HTML form where the user can confirm his or her information and then answer your marketing question. You also need to be prepared to handle the cases where the ID entered is not a valid one and where the database query returns no results. In Listing 33.8, both the confirmation form and the error messages are handled by VBScript subroutines called by the main VBScript code block. Figure 33.2 shows the response to a valid ID number.

Listing 33.8 Code Listing for promo1.asp


<%
dim error
dim ID
error=””

if Not(IsNumeric(request.form(“ID”))) then   ‘ID Not Numeric - stop
   call sub_error                  ‘ call error and don’t come back
else
   ID=request.form(“ID”)         ‘ ID Fine, continue

‘ Create Connection
set dConn=Server.CreateObject(“ADODB.Connection”)
dConn.Open “promotion”

‘ Build SQL statement
SQL=      “Select * “
SQL=SQL + “FROM Clients “
SQL=SQL + “WHERE ClientID=“ & request.form(“ID”)

‘ Execute Query
Set dRS=dConn.Execute(SQL)

if (dRS.EOF) AND (dRS.BOF) then    ‘ No record exists, print error
    call sub_empty
else
    call sub_Confirm
end if

‘ Clean Up RecordSets for Better
 ‘ memory management
dRS.Close
Set dRS=Nothing

end if   ‘ Else from Login Error

‘ BEGIN SUBPROCEDURES

‘ Sub ERROR:  Provide user with message stating that entered ID is
‘ invalid, provide link to return to main page and start again

Sub sub_error
%>
<HTML><HEAD><TITLE>Invalid ID Number</TITLE></HEAD>
<BODY BGCOLOR=”WHITE”>
<H1>Invalid ID Number</H1>
The ID number you entered is not valid.  Please click the Continue
button below and re-enter the number from the letter you received in the
 mail.<P>
<FORM ACTION=”index.html” MEHOD=”POST”>
<INPUT TYPE=”SUBMIT” VALUE=”Continue”
</FORM>
</BODY></HTML>
<%
end sub

‘ Sub empty:  Tells user no matching records were found and reprompts for
 promotion ID number. 
Sub sub_empty
%>
<HTML><HEAD><TITLE>No Matches Found</TITLE></HEAD>
<BODY BGCOLOR=”WHITE”>
<H1>No Matches Found</H1>
No records in our database matched the ID number you entered.  Please
click the Continue button below and re-enter the number from the letter
you received in the mail.<P>
<FORM ACTION=”index.html” MEHOD=”POST”>
<INPUT TYPE=”SUBMIT” VALUE=”Continue”
</FORM>
</BODY></HTML>
<%
end sub

‘ Sub Confirm:  Provide user with current data from database and
‘ allow user to update/modify information. 

sub sub_confirm
%>
<HTML><HEAD><TITLE>Contact Information</TITLE></HEAD>
<BODY BGCOLOR=”WHITE”>
Please review the information below, making corrections where necessary. 
 Click the “Continue” button when you’re finished.

<FORM ACTION=”promo2.asp” METHOD=”POST”>
<TABLE>
  <TR>
   <TD><B>First Name</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”FirstName” VALUE=”<%=dRS(“FirstName”)%>”
        SIZE=35></TD>
  </TR>
  <TR>
   <TD><B>Last Name</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”LastName” VALUE=”<%=dRS(“LastName”)%>”
        SIZE=35></TD>
  </TR>
  <TR>
   <TD><B>Title</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”Title” VALUE=”<%=dRS(“Title”)%>” SIZE=35></TD>
  </TR>
  <TR>
   <TD><B>Company</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”Company” VALUE=”<%=dRS(“Company”)%>”
       SIZE=35></TD>
  </TR>

     <%if (NOT IsEmpty(Address2)) then%>
  <TR>
   <TD ROWSPAN=2 VALIGN=”TOP”><B>Address</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”Address1" VALUE=”<%=dRS(“Address1”)%>”
        SIZE=35></TD>
  </TR>
  <TR>
   <TD><INPUT TYPE=”TEXT” NAME=”Address2" VALUE=”<%=dRS(“Address2”)%>”
        SIZE=35></TD>
  </TR>
     <%else%>
  <TR>
   <TD ROWSPAN=2 VALIGN=”TOP”><B>Address</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”Address1" VALUE=”<%=dRS(“Address1”)%>”
        SIZE=35></TD>
  </TR>
  <TR>
   <TD><INPUT TYPE=”TEXT” NAME=”Address2" VALUE=”<%=dRS(“Address2”)%>”
        SIZE=35></TD>
  </TR>
     <%end if%>
         <TR>
   <TD><B>City</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”City” VALUE=”<%=dRS(“City”)%>” SIZE=35>
   </TD>
  </TR>
  <TR>
   <TD><B>State</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”State” VALUE=”<%=dRS(“State”)%>” SIZE=35>
   </TD>
  </TR>
  <TR>
   <TD><B>Zip Code</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”Zip” VALUE=”<%=dRS(“Zip”)%>” SIZE=35>
   </TD>
  </TR>
  <TR>
   <TD><B>Phone</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”Phone” VALUE=”<%=dRS(“Phone”)%>”   
     SIZE=35></TD>
  </TR>
  <TR>
   <TD><B>Fax</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”Fax” VALUE=”<%=dRS(“Fax”)%>” SIZE=35>
   </TD>
  </TR>
  <TR>
  <TD><B>Email</B></TD>
   <TD><INPUT TYPE=”TEXT” NAME=”Email” VALUE=”<%=dRS(“Email”)%>” SIZE=35>
   </TD>
  </TR>
  <TR>
   <TD COLSPAN=”2"><HR NOSHADE WIDTH=”100%”></TD>
  </TR>
  <TR>
   <TD COLSPAN=”2"><B>Are you a decision maker for
    technology purchases?</B></TD>
  </TR>
  <TR>
    <TD><INPUT TYPE=”RADIO” NAME=”Decide” VALUE=”1">
        Yes</TD>
    <TD><INPUT TYPE=”RADIO” NAME=”Decide” VALUE=”0">
        No</TD>
  </TR>
  <TR>
    <TD COLSPAN=”2"><B>How much will you spend on new
     equipment this year?</B><BR>
    </TD>
  </TR>
  <TR>
    <TD COLSPAN=”2"><INPUT TYPE=”TEXT” NAME=”Amount”></TD>
  </TR>
  <TR>
    <TD COLSPAN=”2"><INPUT TYPE=”Submit” NAME=”Continue”></TD>
  </TR>
</TABLE>
<INPUT TYPE=”HIDDEN” NAME=”ID” VALUE=”<%=ID%>”>
</FORM>
</BODY>

</HTML>
<%
end sub
%>


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.