Advertisement
2002ASP Miscellaneous #8536

FOOApp

The FOOApp: A complete Classified Ads application showing how to use Active Server Pages' ADO database techniques, SQL techniques, cookies for "remembering", VBScript client-side field validation, and much more. FREE!

AI

KI-Zusammenfassung: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Quellcode
original-source
<p><font size="2" face="Verdana">The most common approach to teaching the
fundamentals of any programming language is to start with theory, then the
features, the basic concepts, some techniques, and finally, finishing with a
glimpse of the guts of a real application. I, on the other hand, learn best by
taking something functional and dissecting it into little lessons that expose
the integration of those concepts, techniques, and features of the language. The
undestanding of the interplay of these dissections is what seems most important
to me in becoming a better programmer. This is the way I learn best, and this is
also the approach I will use for teaching you some of the cool things you can
quickly replicate on your own with Active Server Pages.</font></p>
<p><font size="2" face="Verdana">I designed the FooApp (Forum for Online
Opportunities) to &quot;show-off&quot; how simple it is to build a
self-maintaining database application with ASP. People set up their own
passwords; maintain their own member profiles; they can add, edit, or delete,
information they &quot;own&quot;; they can search etc. The application will run
on any machine that supports active server pages and an Access database.
Converting the application for use with SQL is a matter of pointing your
datasource to an SQL server whose table names and fields are the same as those
that exist in the Access dabase. This application is designed for beggining to
intermediate ASP'ers who have at least perused the tutorials found elsewhere on
the site. It is also good for advanced ASP'ers interested in learning a few
tricks etc. but remember the application is not perfect. If you want to make any
additions to the application for others to benefit from, please <a href="mailto:[email protected]"><font color="mediumblue">e-mail
me</font></a>.</font>
<hr>
<p>&nbsp;</p>
<p><strong><font size="2" face="Verdana">*IMPORTANT</font></strong></p>
<p><font size="2" face="Verdana">1. If you download the source code all I ask is
that you take five seconds out of your surfing schedule and visit at least one
of our sponsors- it's an extremely fair trade don't you think? Now that we have
that out of the way, just <a href="http://www.aspalliance.com/glenncook/foocode.zip"><font color="mediumblue">download</font></a>the
complete application's source code! This is the exact source code that is
running on DataReturn's server at the ASPAlliance. I am telling you this because
I don't want anyone &quot;testing&quot; a childish prank on the application that
many people will be counting on to help them learn. C'mon I am giving away the
source-code for free- please don't abuse this opportunity!</font></p>
<p><font size="2" face="Verdana">2. The application will not run right
&quot;out-of-the-box.&quot; The first thing you want to do is delete all
instances of &quot;&lt;!--#include virtual = /adshow.asp--&gt;&quot;(This is the
banner rotator for the site) You will also have to set-up a DSN to point to the
Access database that is included, and you will have to edit the cookie
information properly. The DSN name is called &quot;ClassyAds&quot; and the
information about how to edit your own cookie can be found <a href="http://www.aspalliance.com/glenncook/cookiecode.asp" target><font color="mediumblue">here</font></a>.
If you don't know how to set up a DSN there is a brief explanation at the <a href="http://www.aspalliance.com/glenncook/searchcode.asp"><font color="mediumblue">search
tutorial</font></a>. The application has been installed successfully on hundreds
of machines now so if you are receiving errors, check for typos and editing
problems.</font></p>
<p><font size="2" face="Verdana">3. Your frame of reference for these tutorials
should be the the <a href="http://www.aspalliance.com/glenncook/aspjobs/chill.asp"><font color="mediumblue">working
example in the ASP Trenches</font></a>. Try to mentally figure out how the
application is doing this work before digging into the source code explanations.
Visit the application several times and see how it remembers you? Try to search
for your information several ways, and edit your profile. Important: Look at the
asp page names in your browser as you interface with it. Also as you dig into
the source code you will notice the unconventional variable names that I use-
Simpsons characters. This is a way for me to keep laughing while I program. You
should see the faces on management when I present them with the documented
source code for the projects I've done for them. Now that's REAL funny!</font></p>
<p><font size="2" face="Verdana">4. Ok. Let's start the dissection process- Your
fetal pig is waiting....Have Fun!</font></p>
<p><font size="2" face="Verdana">Go to the<a href="http://www.aspalliance.com/glenncook/aspjobs/chill.asp"><font color="mediumblue">TESTING
GROUND!!!!</font></a></font></p>
<hr>
<p><strong><font size="4" face="Verdana">Cookielog.asp</font></strong></p>
<table border="1" cellPadding="7" cellSpacing="1" width="685">
 <tbody>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p><font color="green" face="Verdana">&lt;%Response.Buffer = true %&gt;</font></p>
    <p><font face="Verdana">&nbsp;</font></font></p>
   </td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">The &lt;%Response.Buffer = True %&gt; line is
    the way to tell ASP to execute the entire page before sending anything
    back to the client. Otherwise it will just start streaming stuff as it
    executes. You'll find that you need this quite often when Redirecting
    clients to different pages.</font></p>
    <p><font face="Verdana">&nbsp;</font></font></p>
   </td>
  </tr>
  <tr>
   <td vAlign="top" width="61%">
    <p><font color="green" size="2" face="Verdana">&lt;!--#INCLUDE
    file=&quot;adovbs.inc&quot;--&gt;</font></p>
   </td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">The &quot;adovbs.inc&quot; file is a collection
    of VB constants that we can use for accessing a database via ADO. It's a
    header file that gives us tools to connect to a database, recordset,
    etc. and it also gives us little useful functions like RecordCount.</font></p>
    </font></td>
  </tr>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p><font color="green" face="Verdana">&lt;% <font color="black">If </font>Request.Cookies(&quot;Shaft&quot;).HasKeys
    <font color="black">Then</font></font></p>
    <p><font face="Verdana">&nbsp;</font></font></p>
   </td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">This line Requests the client's browser for the
    Shaft cookie! I use HasKeys to validate whether that cookie exists. If
    the person has the &quot;Shaft&quot; cookie then HasKeys will be equal
    to &quot;true&quot; and the next line will execute.</font></font></p>
   </td>
  </tr>
  <tr>
   <td vAlign="top" width="61%">
    <p><font color="green" size="2" face="Verdana">Response.Redirect &quot;memberpage.asp&quot;%&gt;</font></p>
   </td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">Here's how you magically transport the user to a
    new page, and the reason why I set the Buffers to True. I didn't want to
    send any data to the client until I was sure that this was the page I
    was actually going to send to the client. Since the user already has the
    Shaft cookie, they've obviously already signed up as a member and I will
    redirect them to the Member Login page-&quot;memberpage.asp&quot;. For
    kicks go ahead and take set the buffers property to False. Does that
    error code look familiar?</font></font></p>
   </td>
  </tr>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p><font face="Verdana">&lt;%Else%&gt;</font></font></p>
   </td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">This is the starting point for users that have
    never visited the site before. They don't have the &quot;Shaft&quot;
    cookie- the HasKeys property was equal to &quot;False&quot;!</font></font></p>
   </td>
  </tr>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p><font color="green" face="Verdana">&lt;%</font></p>
    <p><font color="green" face="Verdana"><font color="black">If </font>&quot;BadMutha&quot;
    = Request(&quot;ActionType&quot;) <font color="black">Then</font></font></p>
    <p><font color="green" face="Verdana">TheContactName=Request(&quot;ContactName&quot;)</font></p>
    <p><font color="green" face="Verdana">TheComany=Request(&quot;Company&quot;)</font></p>
    <p><font color="green" face="Verdana">ThePassword=Request(&quot;Password&quot;)</font></p>
    <p><font color="green" face="Verdana">TheEmail=Request(&quot;Email&quot;)</font></p>
    <p><font color="green" face="Verdana">TheStatus=Request(&quot;Status&quot;)</font></p>
    <p><font color="green" face="Verdana">TheDomain=&quot;.www.aspalliance.com&quot;</font></p>
    <p><font color="green" face="Verdana">ThePath=&quot;/glenncook/aspjobs&quot;</font></p>
    <p><font color="green" face="Verdana">Response.Cookies(&quot;Shaft&quot;)(&quot;ContactName&quot;)
    = TheContactName</font></p>
    <p><font color="green" face="Verdana">Response.Cookies(&quot;Shaft&quot;)(&quot;Company&quot;)
    = TheCompany</font></p>
    <p><font color="green" face="Verdana">Response.Cookies(&quot;Shaft&quot;)(&quot;Password&quot;)
    = ThePassword</font></p>
    <p><font color="green" face="Verdana">Response.Cookies(&quot;Shaft&quot;)(&quot;Email&quot;)
    = TheEmail</font></p>
    <p><font color="green" face="Verdana">Response.Cookies(&quot;Shaft&quot;)(&quot;Status&quot;)
    = TheStatus</font></p>
    <p><font color="green" face="Verdana">Response.Cookies(&quot;Shaft&quot;).Expires
    = #September 3, 1999#</font></p>
    <p><font color="green" face="Verdana">Response.Cookies(&quot;Shaft&quot;).Domain
    = TheDomain</font></p>
    <p><font color="green" face="Verdana">Response.Cookies(&quot;Shaft&quot;).Path
    = ThePath</font></p>
    <p><font color="green" face="Verdana">%&gt;</font></font></p>
   </td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">This is where this page gets cool!<br>
    &lt;In the voice of an Infomercial host.&gt;<br>
    Not only does it check for an existing cookie, but it also posts its own
    form data to itself , collects the data, and writes the information onto
    the user's system in the form of a cookie! But wait there's more: It
    also writes that information to a database!</font></p>
    <p><font face="Verdana">&lt;End Infomercial Voice&gt;</font></p>
    <p><font face="Verdana">Notice that the first line checks to see if the
    person is posting any information to the page. It just simply Requests
    to see if there was a variable sent called (&quot;ActionType&quot;) and
    if it is equal to a string called &quot;BadMutha&quot;. If the statement
    is equal to true, then the page starts executing all of the cookie code
    you see in this block.</font></p>
    <p><font face="Verdana">The first little paragraph Requests/extracts and
    collects the data that has been posted to it. Each variable is given a
    name that the page can use later on.</font></p>
    <p><font face="Verdana">The second paragraph uses the Response object to
    stick each of those variables that it just collected into contents/Keys
    of a cookie I call &quot;Shaft.&quot; The reponse object literally sends
    that cookie and its keys to the client's machine. (For an in-depth
    cookie tutorial please visit </font></font><font face="Verdana"><a href="http://www.aspalliance.com/glenncook/cookiecode.asp"><font size="2">The
    Cheesy Cookie</font></a><font size="2">!!!</font></font></p>
   </td>
  </tr>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p><font color="green" face="Verdana">&lt;%</font></p>
    <p><font color="green" face="Verdana">dim Status</font></p>
    <p><font color="green" face="Verdana">dim Address</font></p>
    <p>&nbsp;</p>
    <p><font color="green" face="Verdana">Status = Request(&quot;Status&quot;)</font></p>
    <p><font color="green" face="Verdana">Session(&quot;Status&quot;) =
    Status</font></p>
    <p><font size="+0" color="green" face="Verdana">Address =
    Request(&quot;EMail&quot;)</font></p>
    <p>&nbsp;</p>
    <p><font face="Verdana">&nbsp;</font></p>
    <p></font></p>
   </td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">Remember the if statement from the block above?
    Well it's still got work to do. This is where I start the process of
    creating a Member Profile in a database using ADO and SQL.</font></p>
    <p><font face="Verdana">The first thing that I do is create a couple of
    variables:</font></p>
    <p><font face="Verdana">The &quot;Status&quot; variable I use for
    sticking the information collected from the form about wheteher they are
    an &quot;Employer&quot; &quot;Developer&quot; etc. into the
    Session(&quot;Status&quot;) variable that was created in the global.asa
    file. Remember the global.asa file is where we can create variables to
    use across the entire time the user is visiting our site. Any other
    variables &quot;die&quot; as soon as the page is done executing.</font></p>
    <p><font face="Verdana">The &quot;Address&quot; variable is what I will
    use to build my SQL statement. I collect the data by Requesting the
    individual's e-mail address from the posting form.</font></font></p>
   </td>
  </tr>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p><font face="Verdana">1 <font color="green">Set Conn =
    Server.CreateObject(&quot;ADODB.Connection&quot;)</font></font></p>
    <p><font face="Verdana">2 <font color="darkgreen">Set NewCust =
    Server.CreateObject(&quot;ADODB.RecordSet&quot;)</font></font></p>
    <p>&nbsp;</p>
    <p><font face="Verdana">3 <font color="darkgreen">Conn.Open &quot;ClassyAds&quot;,&quot;sa&quot;,&quot;&quot;</font></font></p>
    <p><font face="Verdana">4 <font color="green">NewCust.Open &quot;SELECT
    * FROM ASPLoginUserTbl WHERE&nbsp; _</font></font></p>
    <p><font color="green" face="Verdana">EMail = '&quot; &amp; Address
    &amp; &quot;'&quot;, Conn , adOpenKeyset , adLockOptimistic</font></p>
    <p>&nbsp;</p>
    <p><font face="Verdana">&nbsp;</font></p>
    <p>&nbsp;</p>
    <p><font face="Verdana">&nbsp;</font></font></p>
   </td>
   <td vAlign="top" width="39%"><font size="2">
    <p>&nbsp;</p>
    <p><font face="Verdana">Here's where we make a connection to the
    database, build an SQL statement and execute it!</font></p>
    <ol>
     <li><font face="Verdana">Create an ADODB connection object.</font>
     <li><font face="Verdana">Create a recordset object.</font>
     <li><font face="Verdana">Open a connection to the DSN called Classy
      ads. (The server must have a Data Source Name created in the control
      panel's ODBC icon.)</font>
     <li><font face="Verdana">SQL statement: where I basically say, SELECT
      everything FROM the ASPLoginUserTbl Table WHERE the Email field in
      that table is equal to the contents the Address variable. The other
      &quot;Conn, AdOpenKeyset,..&quot; things are properties of the
      statement's interaction with the database that you can read up on in
      <a href="http://www.activeserverpages.com/tutorials">Charles Carol's</a>
      massive database tutorial pages!</font></li>
    </ol>
    <p><font face="Verdana">*The most common mistake that I run into with
    database programming is an SQL statement typo. If any of the &amp;
    &quot;'&quot;, stuff is driving you nuts you need an SQL primer!</font></font></p>
   </td>
  </tr>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p><font face="Verdana">If <font color="green">NewCust.RecordCount = 0 </font>Then</font></p>
    <p>&nbsp;</p>
    <p><font color="green" face="Verdana">NewCust.AddNew</font></p>
    <p><font face="Verdana">If <font color="darkgreen">Request(&quot;ContactName&quot;)
    &lt;&gt; &quot;&quot; </font>Then</font></p>
    <p><font color="green" face="Verdana">NewCust(&quot;ContactName&quot;) =
    Request(&quot;ContactName&quot;)</font></p>
    <p><font face="Verdana">End If</font></p>
    <p><font color="green" face="Verdana"><font color="black">If </font>Request(&quot;Company&quot;)
    &lt;&gt; &quot;&quot; <font color="black">Then</font></font></p>
    <p><font color="green" face="Verdana">NewCust(&quot;Company&quot;) =
    Request(&quot;Company&quot;)</font></p>
    <p><font face="Verdana">End If</font></p>
    <p><font face="Verdana">If <font color="green">Request(&quot;Email&quot;)
    &lt;&gt; &quot;&quot; </font>Then</font></p>
    <p><font color="green" face="Verdana">NewCust(&quot;Email&quot;) =
    Request(&quot;Email&quot;)</font></p>
    <p><font face="Verdana">End If</font></p>
    <p><font face="Verdana">If <font color="green">Request(&quot;Password&quot;)
    &lt;&gt; &quot;&quot; </font>Then</font></p>
    <p><font color="green" face="Verdana">NewCust(&quot;Password&quot;) =
    Request(&quot;Password&quot;)</font></p>
    <p><font face="Verdana">End If</font></p>
    <p><font face="Verdana">If <font color="green">Request(&quot;Status&quot;)
    &lt;&gt; &quot;&quot; </font>Then</font></p>
    <p><font color="green" face="Verdana">NewCust(&quot;Status&quot;) =
    Request(&quot;Status&quot;)</font></p>
    <p><font face="Verdana">End If</font></p>
    <p>&nbsp;</p>
    </font></td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">&nbsp;</font></p>
    <p><font face="Verdana">Since the SQL statement has executed above, we
    can now see if the Recordset object we created, called &quot;NewCust&quot;,
    has a RecordCount equal to 0. Logically, it should because we've already
    made the assumption that the individual has never been here before.
    Since we all know the evils of assumptions, this if statement covers our
    butt if the user has already filled out a member profile. So if our SQL
    query finds an e-mail address it will increment the record count by one.
    We should only have one member profile per E-mail address!</font></p>
    <p><font face="Verdana">The second line executes if there is no other
    e-mail address in the table that matches. This line actually adds a new
    row to the table. Each line that follows actually inserts the
    information it Requests from the posted form into the individual fields
    in the access table.</font></p>
    <p><font face="Verdana">*Again if the SQL statement references a field
    that doesn't exist in the table, ERROR!</font></p>
    <p><font face="Verdana">&nbsp;</font></font></p>
   </td>
  </tr>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p>&nbsp;</p>
    <p><font color="green" face="Verdana">NewCust.Update</font></p>
    <p><font color="green" face="Verdana">NewCust.Close</font></p>
    <p>&nbsp;</p>
    <p><font color="green" face="Verdana">Response.Redirect &quot;memberpage.asp&quot;</font></font></p>
   </td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">This little section of code just does some basic
    administrative work . It updates/saves the new row in the Recordset
    called NewCust. And since we're done with it we close it.</font></p>
    <p><font face="Verdana">So at this point we&amp;rsquo;ve written a
    cookie and stuck data into a database - now we want to direct them to
    the Member Login Page. If they have allowed us to use the
    &quot;Shaft&quot; cookie then their e-mail address and password are
    automatically extracted into the page- so they don't have to remember
    their password.</font></font></p>
   </td>
  </tr>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p><font face="Verdana">Else</font></p>
    <p><font color="green" face="Verdana">Response.Cookies(&quot;JonShaft&quot;).Expires
    = Date - 2</font></p>
    <p><font color="green" face="Verdana">Response.Redirect &quot;addresserr.htm&quot;</font></p>
    <p><font face="Verdana">End If</font></p>
    <p><font color="green" face="Verdana">%&gt;</font></p>
    </font></td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">&nbsp;</font></p>
    <p><font face="Verdana">This little section basically references that if
    statement that checks to see if they have already entered a member
    profile before. If the RecordCount property equals anything other than
    &quot;0&quot; then this little section is executed.</font></p>
    <p><font face="Verdana">All it does is &quot;kill&quot; the Shaft cookie
    we just wrote to the user's system by setting it&amp;rsquo;s Expires
    property to two days ago. Then we send them to a little page that says
    something like, &quot;That e-mail address is already in the system&quot;
    or something to that effect.</font></font></p>
   </td>
  </tr>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p><font face="Verdana">&lt;%Else%&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;HTML&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;HEAD&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;TITLE&gt;New Member Login
    Screen&lt;/TITLE&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/HEAD&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;body&gt;</font></p>
    <p><font face="Verdana"><font color="navy">&lt;form
    METHOD=&quot;POST&quot; ACTION=&quot;</font><font color="green">&lt;%=Request.ServerVariables(&quot;SCRIPT_NAME<font size="+0" color="navy">&quot;)%&gt;</font></font><font color="navy" size="+0">&quot;
    Name=&quot;MyForm&quot;&gt;</font></font></p>
    <p><font color="navy" face="Verdana">&lt;input type=&quot;hidden&quot;
    name=&quot;ActionType&quot; value=&quot;BadMutha&quot;&gt;&lt;p&gt;&lt;font
    face=&quot;Verdana&quot;</font></p>
    <p><font color="navy" face="Verdana">color=&quot;#408080&quot;&gt;&lt;big&gt;&lt;strong&gt;New
    Member Login&lt;/strong&gt;&lt;/big&gt;&lt;/font&gt;&lt;/p&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;p&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;Our site does not recognize you as an
    existing member. If you do not have an account yet please fill in your</font></p>
    <p><font color="navy" face="Verdana">personal information below to
    recieve your &quot;member cookie&quot;. If you have somehow</font></p>
    <p><font color="navy" face="Verdana">lost or deleted your &quot;member
    cookie&quot; and you remember your user name and password, you may</font></p>
    <p><font color="navy" face="Verdana">proceed to the member login
    page.&lt;/font&gt;&lt;/small&gt;&lt;/p&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;table border=&quot;1&quot;
    width=&quot;100%&quot; bgcolor=&quot;#FFFFA2&quot; style=&quot;border:
    2px solid rgb(64,128,128)&quot;&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;18%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;Contact Name(First&amp;Last):&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;82%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;ContactName&quot;
    size=&quot;30&quot;&gt;&lt;font</font></p>
    <p><font color="navy" face="Verdana">color=&quot;#FF0000&quot;&gt;*&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;18%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;Company:&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;82%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;&lt;input type=&quot;text&quot;
    name=&quot;Company&quot; size=&quot;30&quot;&gt;&lt;font</font></p>
    <p><font color="navy" face="Verdana">color=&quot;#FF0000&quot;&gt;*&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;18%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;E-mail:&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;82%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;&lt;input type=&quot;text&quot; name=&quot;EMail&quot;
    size=&quot;30&quot;&gt;&lt;font</font></p>
    <p><font color="navy" face="Verdana">color=&quot;#FF0000&quot;&gt;*&lt;/font&gt;&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;18%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;Password:&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;82%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;&lt;input type=&quot;password&quot;
    name=&quot;Password&quot;</font></p>
    <p><font color="navy" face="Verdana">size=&quot;10&quot;&gt;&lt;font
    color=&quot;#FF0000&quot;&gt;*&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;18%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;Verify
    Password:&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;82%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;&lt;input type=&quot;password&quot;
    name=&quot;Password2&quot;</font></p>
    <p><font color="navy" face="Verdana">size=&quot;10&quot;&gt;&lt;font
    color=&quot;#FF0000&quot;&gt;*&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;18%&quot;&gt;&lt;strong&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;Membership category(Select a profile for
    your account):&lt;/font&gt;&lt;/small&gt;&lt;/strong&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td
    width=&quot;82%&quot;&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;&lt;select name=&quot;Status&quot;
    size=&quot;1&quot;&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;option
    value=&quot;Employer&quot;&gt;Employer&lt;/option&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;option
    value=&quot;Developer&quot;&gt;Developer&lt;/option&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;option value=&quot;Graphic
    Designer&quot;&gt;Graphic Designer&lt;/option&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;option
    value=&quot;Contracts&quot;&gt;Contract(s) To Post&lt;/option&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/select&gt;&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;td width=&quot;100%&quot;
    colspan=&quot;2&quot;&gt;&lt;div
    align=&quot;left&quot;&gt;&lt;p&gt;&lt;small&gt;&lt;font
    face=&quot;Verdana&quot;&gt;&lt;input</font></p>
    <p><font color="navy" face="Verdana">type=&quot;reset&quot;
    value=&quot;Clear Form&quot; id=&quot;reset1&quot;
    name=&quot;reset1&quot;&gt; &lt;input TYPE=&quot;submit&quot;</font></p>
    <p><font color="navy" face="Verdana">VALUE=&quot;Submit Info!&quot;
    id=&quot;submit1&quot; name=&quot;submit1&quot;&gt;&lt;/form&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;form METHOD=&quot;POST&quot;
    ACTION=&quot;<font color="green">&lt;%=Request.ServerVariables(&quot;SCRIPT_NAME&quot;)%&gt;</font>&quot;
    Name=&quot;Form2&quot;&gt; &lt;input TYPE=&quot;submit&quot;</font></p>
    <p><font color="navy" face="Verdana">VALUE=&quot;Proceed to Login
    Screen&quot; id=&quot;submit2&quot;
    name=&quot;submit2&quot;&gt;&lt;/form&gt;&lt;/font&gt;&lt;/small&gt;&lt;/td&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/tr&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/table&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;p&gt;&lt;font
    face=&quot;Verdana&quot;
    color=&quot;#FF0000&quot;&gt;&lt;small&gt;&lt;strong&gt;* Required
    information for new</font></p>
    <p><font color="navy" face="Verdana">members. No information collected
    will be redistributed or used for
    spamming.&lt;/strong&gt;&lt;/small&gt;&lt;/font&gt;&lt;/p&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/BODY&gt;</font></p>
    <p><font color="navy" face="Verdana">&lt;/HTML&gt;</font></p>
    <p><font face="Verdana">&lt;%End If%&gt;</font></p>
    <p><font face="Verdana">&lt;%End If%&gt;</font></p>
    </font></td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">&nbsp;</font></p>
    <p><font face="Verdana">Remember that &quot;If&quot; statement from
    way-back-when that checked to see if the user was posting a form that
    had an ActionType equal to the string &quot;BadMutha&quot;? Well, this
    is the HTML for the form!</font></p>
    <p><font face="Verdana">Please notice a couple things:</font></p>
    <ol>
     <li><font face="Verdana">Since I'm posting this form to this asp page
      I extract the pages name from itself by using the
      Request.ServerVariables object-Cool trick!</font>
     <li><font face="Verdana">I have a hidden input field called ActionType
      that I use for finding out if they are posting this form to this
      page-Cool Trick #2</font>
     <li><font face="Verdana">There is also a form that redirects the user
      to the login page. Just in case they don't have cookies enabled.</font></li>
    </ol>
    </font></td>
  </tr>
  <tr>
   <td vAlign="top" width="61%"><font size="2">
    <p><font face="Verdana">&lt;% If <font color="green">Request.Form(&quot;submit2&quot;)
    = &quot;Proceed to Login Screen&quot; </font>Then</font></p>
    <p><font color="green" face="Verdana">Response.Redirect &quot;memberpage.asp&quot;</font></p>
    <p><font face="Verdana">End If%&gt;</font></p>
    </font></td>
   <td vAlign="top" width="39%"><font size="2">
    <p><font face="Verdana">This little section tests to see if the user has
    selected the &quot;Proceed to login screen&quot; button that I put there
    for people who don't want the cookie to remember their password
    information. It just Redirects them to the login page where they will
    need to provide their e-mail address and password information.</font></p>
    </font></td>
  </tr>
  <tr>
   <td colSpan="2" height="30" vAlign="top"><font size="2">
    <p><font color="red" face="Verdana">The remaining portion of this ASP
    page is some advanced client-side VBScript that does some cool input
    field validation. If you don't have the source-code for the FOOApp, you
    can download it at the top of this article. VBScript tutorials will come
    at a later date.</font></p>
    </font></td>
  </tr>
 </tbody>
</table>
Originalkommentare (3)
Wiederhergestellt von der Wayback Machine