CSci 4608 Problem set 2: forms, Perl
Write an HTML page with a registration form that asks the user to
submit the following information:
Validate the form in the following way:
- The name
- The password, which needs to be typed twice. Use the input type
'password' for the password.
- Address, which consists of the street address, city, state, and
zip code. Make the state to be a selection drop-down menu for
state (you don't need to include all the states, 3-4 would suffice).
- Phone number
- e-mail address
- The date when the user would like to hear back from the company
(or whatever), 2 2-character input areas for month and day and one
4-character for the year.
Write the perl script to check the user information (the same way you
have validate it), except for the
password. If it is entered correctly, display it. Otherwise print the
error message (which fields have not been entered correctly). Note
that you cannot assume the that the state is among those given as
options, so you need to check that, too. Make
sure it's reasonably formatted (each piece of information clearly
marked and displayed on its own line).
- Check that the two passwords are the same. Disable the second
password field after it has been validated.
- Check that the zip code has exactly 5 digits (don't worry about a
possible 4-digit extension).
- Check that the phone number has 10 digits. Ignore the separators
(spaces, parentheses, dashes)
- Check the e-mail address to make sure that it has some non-empty
sequence of symbols, the @ symbol, another non-empty sequence,
the dot, and another sequence (possibly including more dots). You
don't need to check whether the domain name is valid.
- Check that the data that the user entered is valid (day <= 31,
month <= 12, year can be any 4 digits). Then check to make sure that
it's some time in the future (use Date() function for that).
Write an HTML page with a form for electronic voting. It should have
at least three options, the user can vote for exactly one of them (use
validation to guarantee that at least one option is selected, and use
a group of radio buttons so that the selection is mutually
Write a Perl script which will keep record of the votes in a text
file. When a vote arrives, it is added to the file. Then the results
are displayed as numbers and as color bars. To set up the color bars,
use tables (one per each voting option) with the background of the
cells representing the option. Each table has just one
row. The width of the table is set based on the number of votes. Here
is an example of what the tables might look like (only you will need
to set the width in the perl program based on the number of votes).
Votes for Bart Simpson:
Votes for Lisa Simpson:
Votes for Maggie Simpson:
Please answer the following questions. Explain your answers, give
examples if needed.
- Is it a good idea to send the password in a form,
the way it's done in Problem 1?
- Some forms have hidden fields that users can't see or enter data
into. Some online shopping companies store the price of a product as a
hidden field. Then on the server side the charge to the user account
is made according to the data sent with the form. Are there any
problems with this approach? Please be specific.
- Problem 2 asked you to store data in a file. Is there a danger of
unauthorized access to the file (for reading or for writing) using
This is a problem set from CSci 4608
course at UMM.
The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.