COP3832, Assignment 4
Due Wednesday 3/15 at the start of class
You are to write two scripts for me. Add links to your server page to each
script. Hand in a printout of each script.
You may use the parse-lib.pl file which contains a function named
get_query. To access this, include the following statements in your
scripts
require '/home/scsfac/downeyt/scripts/parse-lib.pl';
%query = get_query();
After these commands. %query will be the associative array of name/value
pairs of any parameters sent to your script.
You will need to use the split function to separate the choices in
a checkbox or a multiple selection list.
Handing in the assignment: upload the two separate scripts to the web and
hand in a printout of each.
Script 1
Write a script that will display a form containing the following. Choose
a theme of your choice. All the input elements should relate to your theme.
-
A text box
-
A textarea
-
A group of three radio buttons
-
A group of four check boxes
-
A selection list of several options, only one option may be selected
-
A selection list of serveral options, many of the options may be selected.
-
A submit button
-
A reset button
When the form is submitted:
-
Display all the user's choices in a readable text format. Do not display
the data using form elements, just display them as plain text.
-
Add a form to the page with two buttons:
-
Confirm. When pressed, display a thankyou page.
-
Edit. Redisplay the original form.
-
Extra Credit: when the page redisplays, fill the form elements with the user's
previous choices.
Script 2
random.pl
-
Use the GET method.
-
The script will look at the time of day, and check the seconds.
-
The script will display three completely different pages, depending on wether
the seconds have a remainder of 0, 1, or 2 when divided by 3.
-
Each page should contain a different title, pithy phrase, alignment, background
color and text color.
-
Each page should have a submit button that calls the script again.
This will allow the user to redisplay the page, probably with a different
page (but not always a different page).
-
Each page should also contain a count of how many times each of the different
pages has been displayed. Display the three totals in an unordered list.
Label each total so it is easy to tell which page each total refers to.
-
Notes
-
Use this command to get the current seconds:
/usr/bin/date +%S
-
Use the chomp command to remove the final carriage return from the
seconds:
chomp($seconds)
-
Use the % operator to get the remainder when dividing by three:
$page
= $seconds
% 3
$page will now have the value of 0, 1, or 2.
-
Use the ++ operator to add 1 to a total:
$one++
-
Use three hidden fields to store the three page totals. Each time the page
is loaded it should retrieve the value of these three totals from the query
string into three variables. Increment one of these variables each time the
script is called. Use all three to update the contents of the table of totals.
-
Be sure that a 0 displays for a total when the value is 0.