The first step is to set up a new web page that will be used by visitors to post to the message board. In addition to prompting the user for the message content, it should also gather some information about the user (to verify the each user is allowed to post to the board and to display a name on the board along with the message) and allow the user to specify how the message should be displayed (font color and whether or not to convert to all capital letters). The table below shows the types of fields (i.e., form elements) you will need for your page.
Start by creating a new page (e.g., "lab2.html" or "messageBoard.html") in your folder or project and then copying and pasting the page source from the Skeleton Message Board Entry page into your page. The skeleton includes a few sample HTML form elements that you will need on your page and also some extra, temporary code for testing your form elements as you create them.
Read over the code that you have copied, and make sure you
understand the various pieces of the code. (At the end of the lab,
once you have tested everything, you will comment-out the button
that creates the intermediate test results.) As you saw in Mini-Lab
id attribute in each input form element is
used by the
label tag. Notice that each input form
element has a
name attribute that exactly
matches one of the field names in the table below. This is
necessary in order for the page to interact correctly with the
existing message board software on the CS server, which expects to
receive information for fields with those specific names.
value attribute determines what value is
passed to the server for the corresponding field name. For example,
if the existing skeleton code were to be submitted to the CS server,
the data going to the server would consist of two name/value pairs:
"posted_by"/"Alyce Brady" (if that was the value typed into the
field) and "shout"/"yes".
Once you understand the copied code, you are ready to add new
form elements to your page.
(Recommendation: add your elements one at a time, and test each
one before going on to the next.)
Give each field a label.
Remember that the
name attribute must exactly
match the appropriate field name in the table below.
Add appropriate code to the
to test that your new input element acts as you expect.
You can refer to this
sample page of HTML form elements for examples of HTML form elements
that are not in the skeleton page.
Use formatting instructions in HTML (e.g., line breaks, tables, etc) to give your page a nice layout (not in one long line, for example). Preview your page in a web browser to make sure that it looks OK and that all the input form elements have the expected values.
||The body of the message text. This should be collected with a
|| A title for the message. This should be collected with a
||The font color to be used for the message post. This should be
collected with a
||The preferred salutation of the poster (Ms., Mr., none, etc.).
This should be collected with a set of
||The name of the person posting the message. This should be
collected with a
|| The password for the message board. This should be collected with
||A field that determines whether or not the message should be
converted to upper case. This should be collected with a
<input type="checkbox" name="shout" id="shout" value="yes">
The next step is to modify your
<form> tag to
as in the example below, and then to
add a submit button to your form (right after your test results button,
Make sure that the new button is
inside the form, just as your other form elements are.
<!-- MODIFY THE EXISTING FORM TAG TO LOOK LIKE THIS! --> <form action="http://www.cs.kzoo.edu/cs105/labs/MessageBoard/testMsg.php" method="POST" > <!-- YOUR EXISTING INPUT ELEMENTS ARE HERE! --> <input type="submit" name="submit1" value="Submit"> </form>
What is happening here? The form tags serve to tie
together all of the input elements that should be sent to the server
when the "Submit" button is clicked. (It is also possible to have multiple
forms per page, each of which may be associated with a different
action attribute specifies
what should be done with the form's data when the submit button is
clicked. In this case, it will be sent to a page
testMsg.php that will show you the data that was
We won't worry about
method attribute. It determines how the
data is sent.
Once the data on the
testMsg.php page is correct, you are
ready to submit it to the actual message board set up for this lab.
Just change the file associated with the
This will insert the data you submit into a database that the
message board looks at.
Once you have added the action to your form tag and the submit button
to your page, you
should be able to test the message system. Load your page in a web
browser and try to post a message.
(Remember: this is a single message board for the whole class, so
everyone will be able to see your message -- keep it appropriate for a
Try making several posts with
different input settings to make sure that your page is working as it
should. Look at the output on the
but also look at the actual
COMP 105 message board
Once you are satisfied that your page works correctly, remove or comment out the button that creates intermediate test results.
Add a link from your course web page to your new message-posting page.
You should also add a link to the message page
either from your course web page or from the page used to make the
posts. Add HTML comments to your newly created pages containing:
Publish your completed pages to the web server and test them to make sure that they still work as expected.