COP3832, Assignment 6
Due Wednesday 4/18 at the start of class.
Upload the script and hand in a printout.
Create one script file that does the following. All code and HTML for this
assignment should be in one CGI file.
Use POST when submitting the data from the browser to the server.
There will be several different HTML pages displayed by this script
-
The Login Page. If there is a cookie for this page that contains the
user's Phone Number, then skip the Login Page and go directly
to the Form Page, using the Phone Number from the cookie to
access the data base and fill in the data on the Form Page. Use a
shared lock when reading from the database. If there is no cookie, then display
an empty Login Page.
-
The Form Page. If the user's Phone Number is in the database,
then fill in the form elements with the data from the database. Use a shared
lock when reading data from the database. If there is data in the query string,
then it should be used to fill in the form elements.
-
The Confirmation Page.
-
Each page should include a header and a footer. These files should be in
the /includes directory of your server. Unfortunately, SSI
commands do not work in CGI output, so you will have to open the files
and include them in each page that is displayed. The header should contain
some information about the script that you are creating. The footer should
contain some information about your website. Each page will display the same
header and footer.
-
Use the same style sheet to control the look of each page.
The Login Page will display a form with a Submit button , a
text box for the Phone Number, and a text box for an E-mail
Address.
-
Both text boxes should be "sticky".
-
The E-mail Address may not be blank, and must contain an @ sign with
some some charcters before it and after it. It may not contatin more that
one @ sign.
-
Validate that the Phone Number is in one of these formats: (999)
999-9999; (999) 999 9999; (999) 9999999; 999-999-9999; 999 999 9999;
999.999.9999; 999999999.
-
If the Phone Number is invalid, then redisplay the Login Page
with an appropriate error message.
-
If the Phone Number is valid, then display the Form Page as
follows
-
If the Phone Number is already in the database, then fill in the Form
Page with the user's data.
-
If the Phone Number is not in the database, then display an empty
Form Page.
The Form Page will have the following.
-
Display the Phone Number on the page as plain text (do not display
it in a form element). Display it in the format (999) 999-9999, regardless
of how the user entered it.
-
Display the E-mail Address on the page as plain text (do not display
it in a form element).
-
Have a checkbox on the page with the label: Save Phone Number in cookie.
If checked, then the Phone Number will be stored in a cookie when
the user submits the page. The cookie should expire in one minute
and should only be readable by this script.
-
Have a checkbox on the page with the label: Remove cookie. If checked,
then the cookie containing the Phone Number should be deleted when
the page is submitted.
-
The rest of the form will work just like it did in homework 5.
-
A Submit button. When this information is submitted, the script should
verify that each field has been filled in or selected, and that it meets
the requirements from Homework 5.
-
If there are invalid fields, then redisplay the Form Page with appropriate
error messages, and change the background color of each <td> element
that contains an invalid field. Use your stylesheet to control the color.
Be sure that the user's previous choices are still visible.
-
If all the fields are valid, then display the Confirmation Page.
The Confirmation Page will have the following:
-
Display the user's information as plain text (do not display them in form
elements.)
-
Display the following buttons in a form:
-
Edit: if clicked, then the Form Page is redisplayed, with all
of the user's information filled into the form. Use the information from
the Confirmation Page, not the information in the database. The Phone
Number and E-mail Address should still be displayed as plain text.
-
Confirm: if clicked, then write the user's information to a
database, including the E-mail Address. Do not write to the database
until this button is clicked. Use an exclusive lock when writing to the database.
Use the Phone Number as the key field. Redisplay the Confirmation
Page with with an extra message indicating that the data has been entered
into the database. Send a message containing all of the user's information
to the E-mail Address.
-
New User: if clicked, then display an empty Login Page. If
this button is clicked, then an empty Login Page should be displayed,
even if there is a cookie.
Please note that the data is not entered into the database until the
user presses Confirm on the Confirmation Page.