• CSC 363 Lab #5 - PHP Lab #2:
  • Due Date:  June 3, 2009 (due dates will be in the Task list in Blackboard)
  • Generate Dynamic Web Page Content Using Form Data
  • 50 points distributed as follows:

In this project,  you'll write a PHP program that constructs a humorous news story. The program lets the user enter some text strings and then assembles the strings into a story. Here are a couple of interactive examples of how your lab should work.

Form Input #1:

Corresponding News Flash Output:

Note that the second line of output displays the current date.  You should use php's date function so that the date displayed will always be the current date. (See page 298-300 of the  Visual Quickstart textbook.)

Form Input #2:

Corresponding Output:

 

Publish a link to your form page PHPLab2.htm, on your course home page on the profhicks.com server account space. Upload your php file PHPLab2.php  to your server space also. (You must use this name or change the ACTION tag within the form tag highlighted in gold below>)

HTML code in form page phpLab2Form.html

<HTML>
<HEAD>
<TITLE>PHP Project #2</TITLE>
</HEAD>
<BODY>
<!-- File phpLab2Form.html -->

<FORM   METHOD="POST" ACTION="phpLab2.php">
<TABLE>

<TR>
<TD ALIGN="RIGHT">User's First Name:</TD>
<TD><INPUT TYPE="TEXT" NAME="USER"></TD>
</TR>

<TR>
<TD ALIGN="RIGHT">Major City:</TD>
<TD><INPUT TYPE="TEXT" NAME="CITY"></TD>
</TR>

<TR>
<TD ALIGN="RIGHT">Favorite Ice Cream Flavor:</TD>
<TD><INPUT TYPE="TEXT" NAME="FLAVOR"></TD>
</TR>

<TR>
<TD ALIGN="RIGHT">Favorite Pop Music Star:</TD>
<TD><INPUT TYPE="TEXT" NAME="STAR"></TD>
</TR>

<TR>
<TD ALIGN="RIGHT">Name of Famous River:</TD>
<TD><INPUT TYPE="TEXT" NAME="RIVER"></TD>
</TR>

<TR>
<TD></TD>
<TD><INPUT TYPE="SUBMIT"></TD>
</TR>

</TABLE>
</FORM>
</BODY>
</HTML>  

Note:  Fields that are highlighted in blue, represent data that will be used by your php program, in printing the news Flash.

The php file PHPLab2.php  that processes this form data will contain mostly html code, except where form data fields are inserted into the text.  Here is a view from Dreamweaver of the file PHPLab2.php, where the php code is not implemented, but appears as a little icon on the page.

.

Here is the same page with php fields highlighted with field names from phpLab2Form.htm.

When you view a php file in a browser, what you see is the html code generated by the php code.  Because of this, I would like you to submit  your php page in Blackboard in addition to uploading it to your profhicks server space.  (Upload the phpLab2.php file in Blackboard just like you submit your C++ programs in Blackboard.  You do not need to upload your  html page in blackboard, but of course you do need to upload both files to your profhicks web server space.)

 
Task Points Description
A
5
Your home page has a link to the phpForm.html page, that contains all five text fields plus a submit button.  When the submit button is pressed, your form data is sent to a php page for processing.
B
5
You have uploaded your file phpLab2.php to Blackboard.
C
10
Your php generated form results page includes the current date, using a date function.
E
5
Your php generated form results page includes the basic text, formatted as displayed in screen captures.
F
5
Your php generated form results page includes form fields CITY as displayed in screen captures.
G
5
Your php generated form results page includes form field RIVER as displayed in screen captures.
H
5
Your php generated form results page includes form field STAR as displayed in screen captures.
I
5
Your php generated form results page includes form field USER as displayed in screen captures.
J
5
Your php generated form results,  page includes form field FLAVOR as displayed in screen captures.
 
50
Total

[top]