Assignment 4
Due Tuesday 3/31 at the start of class
When you are done, send me an e-mail message. Also, hand in a printout of
all three scripts.
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. This function only works for
the GET and POST methods. See the Notes under isindex.pl to
see how to retrieve the keywords from an ISINDEX request.
You are to create an HTML document in the root of your server named
scripts.html. On this page you will have links to three scripts:
isindex.pl, random.pl, and confirm.pl
-
isindex.pl
-
Write a script that uses the <ISINDEX> tag.
-
If the script is called without any parameters, display a page that will
allow the user to type in a series of keywords.
-
If the script is called with parameters, display a page that displays an
unordered list of the keywords that were entered, then display a horizontal
line, then display the page that allows the user to type in a series of keywords.
-
As long as the user continues to enter a list of keywords, the unordered
list at the top of the page should change to reflect the new list.
-
Include a title on your page.
-
Notes
-
The @ARGV array is a special array that will contain the list of keywords
from an <ISINDEX> tag.
-
This will retrieve the length of the @ARGV array:
$length = scalar
@ARGV
-
Use the length to determine if any keywords were submitted. If the length
is 0, then no keywords were submitted.
-
-
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 redisplay the page, probably with a different page
(but no 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 a table. 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.
-
-
confirm.pl
-
Use the POST method
-
When this script is called with no parameters, then display a form that
incorporates all the input form elements, except the hidden type (you
used that one in random.pl). Give the button the label Submit.
-
Create a table so that all the form elements are aligned nicely.
-
Make four of the fields required. When the form is submitted with parameters,
the script must check that the four required fields have been filled in.
-
If any of the fields are empty, then display a nice table of the required
fields that are empty, and redisplay the form. When the form is redisplayed,
all the fields that were filled in should display the values that they were
given.
-
If all of the required fields are filled in, then redisplay the form with
all the fields displaying the values they were given, and ask the user to
confirm that the information is correct. Change the name of the Submit
button to Resubmit, and display another button named Confirm.
Be sure each button has a name which can be tested by the script to determine
which button was pushed. Resubmit allows the user to change any fields,
it is just the same as the Submit process before, only the name of
the button has changed. Confirm completes the script.
-
When the user confirms that the information is correct by pressing the
Confirm button, then respond with a confirmation message and thank
the user.
-
Note that you aren't actually doing anything with the final data. We'll do
that later.
-
Notes
-
You can also use
scalar %query
to determine if the query associative
array has any elements. however, this time, scalar returns true if it has
elements and false if it doesn't.
-
You might make use of an array that you can create like this
@must = ('field1','field2','field3')
filling in the names of your required fields.
-
You might also consider creating an array named
%dont_have
-
You might make use of a hidden field that you make appear as a button at
an appropriate time.