Assignment #5c
PHP Image Randomizer & Survey
Level of Difficulty: Moderately Easy
Potential Points: 100 out of 100
You are to create a survey. The survey must ask 6 questions; the responses
entered by the user are to be validated and reprinted to the screen. The survey
may be your choice; whether it's related to your research, job, class(es), etc.
The script will look something like the Movie
Starz Rental Survey from php/, with a few differences.
Once the input is successfully validated, the results/answers are sent to the
administrator (you), in a text readable format. Also, a randomly generated coupon,
from a set of three, should be printed on this page.
Grading
- HTML Well-Formedness & Validation - All resulting HTML should conform
to the transitional HTML DTD - transitional because you are permitted to use
the table style attributes.
- Form Element Validation - All form elements from the survey should be present
as variables once the form is submitted; i.e. if any question is unanswered,
notify the user of what the error is and what he/she needs to do to fix it.
- Labeling - I should know what the form does and where data goes at the interface
level (i.e. I should know this is an online dictionary). All form elements
should be labeled within the HTML tags and in the rendered HTML. You should
also give the form elements a 'meaningful' value for the 'name' attribute.
Don't forget, this value is converted into a variable in PHP and values are
assigned to the variables using the 'value' attributes.
- Branching - There should be four separate printouts:
- the default page when it's first loaded
- the submitted page with appropriate user error message(s) (missing form
elements)
- the page with the mail error (in case the mail function doesn't work)
- the 'success' page with the randomly generated coupon & reprinted
answers.
- Legibility - Make sure you put in comments and indentions (if-else statements)
to make the PHP code more ledgible. You don't have to comment on every line
of code...try to group comment descriptions. The answers sent to the administrator
should be in a ledgible format; i.e. I should be able to direct the form to
myself and make sense out of the incoming emails.
Specifications
- Use one script/file. The form should submit to itself. (i.e. $PHP_SELF).
- You should have 6 questions; of those 6 questions, it is required that:
- two are choose one or the best that applies (all radio buttons)
- two are choose as many that applies (all checkboxes)
- one be a multi-line (at least 4 rows) textbox
- one be a single-line textbox.
- Once the page has been successfully validated, the answers should be sent
to the administrator in a ledgible format using the mail function. In the
mail function call, use a variable called $email_addr that is declared and
assigned a value (your email address) outside of the call itself.
- The coupon should be randomly generated from a set of 3 images. These are
images you create.
- The 'success' page should contain the date the user completed the survey
somewhere on the bottom of the screen. (Hint: use the date function.)
- Only use PHP and HTML...no JavaScript or other client-side technology.
- Use your own code! You may use the examples from the class and examples
but do not copy and paste. Do not use already existing code on other sites...I'm
quite aware of what is available.
- Send the form data using the POST method.
Notes
- The overall appearance and topic of the survey is up to you.
- Use the mail and date functions built into PHP.
- For the email message and simplicity's sake, assign the user input to a
string variable with occasional newline characters. If you need to start on
a new line or need to break up the string, don't forget to use concatenation
. & .=
- Use Dreamweaver to build your basic template. Don't be afraid to use Flash
for drawing/creating your coupons; it's your choice.
- Using mailto:[email address] command in the action attribute of the form
tag produces hard-to-read data. Your script should make reading submitted
data simple.
You are to post your script in a web accessible directory in your Ruby account.
The script should also be sent to me at burta at ibiblio dot org.
Andre S. Burton