gotFusion.com....... Where your adventure begins
Full Service Web HostingNetObjects Fusion 7 Websites Portal

 


 

The GuestBook action page and GuestBook View

Now that we have created the Form, we now have to create:
  • actions to check the form for missing data,
  • actions to append the data to the guestbook table
  • and actions to post the results in a viewable table structure.

This example uses a DSN-Less Connect Method
Here again is the Link to the access DB
Steps to Create the page in NetObjects Fusion

"Inside the Head" Tag
First we want to make sure our required fields contain
The information we need so we will first evaluate the
length of the data to determine if values were placed
inside the fields. We do this to make sure blank records
are not recorded into the table. Once we have determined
the data is present we append a record to the table.

First Create a New Page in Site ---> Outline view
Name the page GuestBook and change the extension to ASP

Go to Page view.

From the Layout Properties Pallet Click HTML
"Inside the Head" tag place the following
If you plan on copy and pasting this code first run it through NotePad to remove formatting

<%
Response.Buffer = True
Dim connStrx, Name1, City1, State1, Country1, Email1, Message1, Homepage1, rs, fh2, fhc2, fhc3

' Here we are setting the variables for connection to our database and creating an Object
' in order to to open a recordset for appending data


connStrx = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("guestbook.mdb")
Set rs = CreateObject("ADODB.Recordset")

' Now that we have dimensioned variables, lets make sure we even have data to look at.
' Since this page is also the results page we need to verify there was a form submission request.


If Request.Form("Submit")="Sign-It" Then

' this checks if the form was submitted. Once we can determine this is true we can
' assign the variables we dimensioned above to hold the form data.


Name1=Request.Form("Name")
City1=Request.Form("City")
State1=Request.Form("State")
Country1=Request.Form("Country")
Message1=Request.Form("Message")
HomePage1=Request.Form("Homepage")
email1=Request.Form("Email")

' Now that we have filled the variables with the form data we can verify the required
' fields indeed have information. To do this we look at the length of the string data
' we aquired from the form. If the length of the data is 0 we can assume the field was
' skipped over and no information was inserted.

   If len(trim(name1))=0 or len(trim(city1))=0 or len(trim(state1))=0 or len(trim(country1))=0 Then
   response.write "<center><h3><font color=red>Missing Required Data. Try again</font></h3>"

' You can stop here and give a link back to the form or you can let the visitor know
' exactly which fields they missed. To do that we look at each required field and
' determine if the condition is true. If it is we issue a write statement to inform
' the visitor of what fields are missing data.

  if len(trim(name1))=0 then
  response.write "Missing Your Name<br>"
  else
  end if

  if len(trim(city1))=0 then
  response.write "Missing your City<br>"
  else
  end if

  If len(trim(State1))=0 then
  response.write "Missing your State or Providence<br>"
  else
  end if

  If len(trim(country1))=0 then
  response.write "Missing your Country<br>"
  else
  end if

' Now that we have supplied the visitor with information about the missing data
' We create a link to go back to the form and finish inserting values properly.


response.write "<a href='javascript:history.back()'><h4><font color=red><b>CLICK HERE TO FINISH FORM AND RE-SUBMIT</b></font></h4></a></center>"

   Else

' if the simple logic test passes an required fields contain data,
'  we can submit the data to append to our table when we designed the table we included
' a  date field and time field to automatically insert the current date and time so we can just
' concentrate on form data.


  rs.Open "Guestbook", connStrx, 2, 2
  rs.AddNew
  rs("Name") = Name1
  rs("City") = City1
  rs("State") = State1
  rs("Country") = Country1
  rs("Email") = Email1
  rs("Message") = Message1
  rs("homepage") = Homepage1
  rs.Update
 
' Once we insert the data we close the connection and later re-open it to retreive all the data for viewing.

 
rs.Close
  response.write "<center>Thanks for signing the GuestBook<br><a href='guestbook.asp'>Click here to view your entry</a></center>"

' This is our success response. It includes a link to view the results.
' Notice the link is the same as the page we are creating

  End If

Else
%>
 


Click Next to continue

View the PREVIOUS page in this tutorial

Return to the TOP of this page

View the NEXT page in this tutorial


|  Fusion  |  Web Design  |  Hosting  |  Resources  |  gotFusion Store  | 

Problems with this page?  

All content copyright © 2002 gotFusion LLC.  The name gotFusion and the gotFusion ® logo are registered trademarks of gotFusion LLC
Copyright, legal notice & privacy statement