Make the Code

This code will create a simple web site with a default page and a menu at the top with three links: Home, About Us, and the registration page. The registration page will have a form to fill out, which will submit information to a database so we can send out the monthly newsletter. This site will have six files, as detailed in Figure 19-5.

click to expand
Figure 19-5: Directory listing of the files

Here is the sample code for each of the files.

Default.htm

<<HTML>>  <<HEAD>>   <<TITLE>>    Beer Brewers Home Page   <</TITLE>>  <</HEAD>> <<frameset rows="60,*">>  <<frame name="banner" scrolling="no" noresize target="main" src="/books/1/196/1/html/2/top.htm">>   <<frame name="main" src="/books/1/196/1/html/2/about:blank">>  <</frameset>>  <<noframes>> <<BODY>> <<p>>This page uses frames, but your browser doesn't support them.<</p>> <</BODY>>  <</noframes>> <</HTML>> 

HomePage.htm

<<HTML>>  <<HEAD>>   <<TITLE>>    Beer Brewer's Home Page   <</TITLE>>  <</HEAD>> <<BODY>> Welcome to the Beer Brewer's site. Please sign up for the newsletter. <</BODY>> <</HTML>>

SignUp.htm

<<HTML>>  <<HEAD>>   <<TITLE>>    Sign up for the newsletter!   <</TITLE>>  <</HEAD>> <<BODY>> This form will sign you up to receive the Beer-Brewers.com newsletter. You can get the newsletter by email and postal mail.<<br>> <<form METHOD="POST" target="main" ACTION="https://www.beer-brewers.com/SignUpPost.asp">>  <<table BORDER="0">>   <<tr>>    <<td>><<b>>First Name<</b>><</td>>    <<td>><<input TYPE="TEXT" NAME="FirstName" SIZE="50">>   <</tr>>   <<tr>>    <<td>><<b>>Last Name<</b>><</td>>    <<td>><<input TYPE="TEXT" NAME="LastName" SIZE="50">>   <</tr>>   <<tr>>    <<td>><<b>>Street Address<</b>><</td>>    <<td>><<input TYPE="TEXT" NAME="Address" SIZE="50">>   <</tr>>   <<tr>>    <<td>><<b>>City<</b>><</td>>    <<td>><<input TYPE="TEXT" NAME="City" SIZE="50">>   <</tr>>   <<tr>>    <<td>><<b>>State<</b>><</td>>    <<td>><<input TYPE="TEXT" NAME="State" SIZE="50">>   <</tr>>   <<tr>>    <<td>><<b>>Zip Code<</b>><</td>>    <<td>><<input TYPE="TEXT" NAME="Zip" SIZE="50">>   <</tr>>   <<tr>>    <<td>><<b>>Country<</b>><</td>>    <<td>><<input TYPE="TEXT" NAME="Country" SIZE="50">>   <</tr>>   <<tr>>    <<td>><<b>>Email Address<</b>><</td>>    <<td>><<input TYPE="TEXT" NAME="Email" SIZE="50">>   <</tr>>  <</table>>  <<br>>  <<input TYPE="Submit" value="Submit">> <</form>> <</BODY>> <</HTML>> 

SignUpPost.asp

<<HTML>>  <<HEAD>>   <<TITLE>>    Server   <</TITLE>>  <</HEAD>> <<BODY>> <<% ' Set up and open the database using the DSN Set conn = Server.CreateObject("ADODB.Connection") Set rs = Server.CreateObject("ADODB.Recordset") conn.open "DSN=BeerBrewersDSN;" rs.open "BeerBrewersTable", conn, 2, 3 ' Add a new record using all the fields in the form  rs.addnew  rs("FirstName") = request("FirstName")  rs("LastName") = request("LastName")  rs("Address") = request("Address")  rs("City") = request("City")  rs("State") = request("State")  rs("Zip") = request("Zip")  rs("Country") = request("Country")  rs("Email") = request("Email") ' Update the records and close the connection  rs.update  rs.close  conn.close ' Always close out the objects to eliminate memory leaks SET conn = Nothing SET rs = Nothing %>> Your information has been updated. You will receive the newsletter in 4-6 weeks Thanks! <</BODY>> <</HTML>> 

Top.htm

<<html>> <<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">>  <<table width="100%" height=60 border="0" cellspacing="0" cellpadding="0">>   <<tr>>    <<td valign="middle" align="center">>    <</td>>    <<td valign="middle" align="center">>     <<p align="center">><<a target="main" href="homepage.htm">>Home<</a>><</p>>    <</td>>    <<td valign="middle" align="center">>     <<p align="center">><<a target="main" href="https://www.beer-brewers.com/ signup.htm">>Sign up for the newsletter<</a>><</p>>    <</td>>    <<td valign="middle" align="center">>     <<p align="center">><<a target="main" href="https://www.beer-brewers.com/ NewsLetter.htm">>Current Newsletter<</a>><</p>>    <</td>>    <<td valign="middle" align="center">>     <<p align="center">><<a target="main" href="UnderConstruction.htm">>About Us<</a>><</p>>    <</td>>   <</tr>> <</table>> <</body>> <</html>>

UnderConstruction.htm

<<HTML>>  <<HEAD>>   <<TITLE>>    Under Construction   <</TITLE>>  <</HEAD>> <<BODY>>  This page is under construction. Please come back later. <</BODY>> <</HTML>>

This code applies to the production site. The data for the production and test sites is the same, except for the database table name and URL of the test site. One set of these files would be in the production directory, and one set would be in the test directory. The newsletter.htm page is just the newsletter and doesn't have any relevant code, so it's not listed here.




IIS 6(c) The Complete Reference
IIS 6: The Complete Reference
ISBN: 0072224959
EAN: 2147483647
Year: 2005
Pages: 193

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net