CNT4713 Extra Credit 5
Due by Wednesday, 11/23
Worth extra 3 points
Refer to the section on the class page entitled
CGI scripts that parse data and process web forms for videos that
will help with the assignment.
Write a script that displays a form for entering fields for an email. The script will validate
that all the data is correct and then send the email using the smtp.cs.fiu.edu server.
-
Write a CGI script on ocelot.
- When the script is called, display a page with a form that has fields for From, To, Subject and Message.
-
Parse all the data that is sent via the form from a browser.
-
Validate that each email address contains the @ sign and that the subject and message are not empty. If the data is not valid, redisplay the page with the data displayed in its original field and with appropriate error messages.
-
Once the data is valid, send an email using the smtp.cs.fiu.edu server.
-
You may not use exisiting frameworks and modules that process web forms.
Suggestions
- Distinguish between GET and POST requests by examining the REQUEST_METHOD header.
Only show error messages from POST requests.
- Use my mod_html.py module to parse the request data. You must know how it works,
but you may use it to complete the assignment.
- Use methods to encapsulate tasks.
- Use a multiline string and format it to generate the HTML page with the data and errors in it.
- Lists are more difficult to use than dictionaries, in a format string.
Modify index.html
I want to be able to run your scripts on ocelot, without having to type the
name of each script in the URL.
- Modify the
index.html
from extra credit 1 and add a link to this script.
- Use my index page as a reference:
Index Page.
You may copy the source of my page and modify it with your name and the names of your scripts.
Deploying the Assignment
You Must Complete Extra Credit 1
If you did not do extra credit 1, then you cannot do this extra credit.
Complete extra credit 1, then complete this assignment and submit it.
Create a CGI Script
Modify the script so it is a cgi script. See Extra Credit 1 for details.
Limit Access to the cgi-bin
Be sure that only you and I can access your script in the cgi-bin folder.
Submitting the Assignment
To hand in
the assignment, place all your scripts in the cgi-bin folder on ocelot.
Zip the public_html folder, including the cgi-bin folder.
DO NOT USE 7-ZIP or RAR!!!
- Please use the following command to your public_html
folder.
zip -r ~/username ~/public_html -x \*.zip
Replacing username with your user name. This will create a file
named username.zip.
- Check the size of the ZIP file, it should be less than 3 MB. If it is
not, then you probably have another ZIP file stored in the ZIP archive.
Delete it and re-zip.
- You then have a choice for submitting the file.
- If you are logged onto ocelot, use my uploading program to upload the
file. Enter this command at the command prompt:
~downeyt/cs/public/webftp/webftp.pl
- If you are using winscp, then download the zip file to your computer;
then, upload the file to me:
Submitting
homework on-line via the Web.
- Upload the file as binary.