Assignment #5b
PHP Mail Form
Level of Difficulty: Moderately Easy
Potential Points: 100 out of 100
You are to create a PHP script that composes an email from input form data.
From an interface you design, send form variables about an email message composed
by the user to the designated address. You are to basically recreate this script.
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 should be present as variables
once the form is submitted. For example, if the subject is missing, print
out the appropriate error message (i.e. 'The subject field is empty'). However,
you do not have to make sure the to and from fields are actual email address
(containing the '@' sign).
- Reprinting Data - If there is a missing variable, not only do you have
to print out the appropriate message, but you also have to reprint the
HTML form with the data the user has already entered.
- Labeling - I should know what the form does and where data goes at the interface
level (i.e. I should know this is an email form). All form elements should
be labeled within the HTML tags and in the browser. For example, I should
know that this is where I put the subject. You should also give the form elements
a value for the 'name' attribute. Don't forget, this value is converted into
a variable in PHP.
- Branching - There should be four separate print outs:
- the default page
- the default page with the appropriate error message
- the 'email was not successfully sent' page
- the 'email was successfully sent' page.
- 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.
Specifications
- Use one script/file. The form should submit to itself (i.e. use $PHP_SELF).
- The subsequent pages should all branch out from the default email page.
The only pages that should reprint the form elements are the default page
with and/or without the appropriate error message.
- Only print one error message at a time.
- You should have a single form containing three single-line textboxes, one
multi-line textbox, a submit button, and a reset button.
- Only use PHP and HTML...no JavaScript or other client-side technology.
- Be sure to give an administrator's email address (i.e. your email) in case
the email is not sent.
- 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
aware of what is available.
- Send the form data using the POST method.
- Do not worry about parsing email addresses (i.e. is $email_to a valid email
address with a '@' and '.'?).
Notes
- The overall appearance of the page is up to you.
- Use the mail function predefined in PHP...it makes things simple. Also refer
to php.net for mail function usage and examples.
- Use Dreamweaver to build your basic template.
- Do not worry about removing the backslash before '.
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@unc.edu. Email me if you have
any questions.
Andre S. Burton