Description
Use the form you created last time to format an email message.
If the input validates, an email should be generated.
Let the user know if the email succeeded.
Assignment
We’ve got a form that a user can enter an email message into, so we’ve almost got a useful page.
All we need to do is make sure that it sends out the actual email. This will be a really easy
project (assuming you got the last project done) that should give you a little extra practice while
we come up to speed with MySQL in class. Don’t procrastinate, and if you get it done quickly
enough you can reward yourself with a little spare time before the next project. Here’s what you
need to do:
Add a subject field to your contact form (if you haven’t already; emails should always have a
subject line. Don’t allow blank subjects.)
Add some kind of drop-down category field: Complaint/Question/Suggestion/Praise/Other or
whatever makes sense for your email form. This data will become part of the body of the
email.
Create a variable with your email address as a string. Why a variable? So you only have to
change it once if your email changes. Think it won’t? I have long had a personal email and
received a school email and just recently the school handed me a second, different email
address to use for teaching. Chances are you’ll get a new one when you get a new job or
change ISPs. Planning ahead now makes changes later much easier.
Create a variable and get the date/time to use as a timestamp.
Now, send the email to yourself (as if a user were entering it on the form, right?) with a copy
to the user. You may find it easier to pair up with others to test that everything is working.
Once you have the form looking right, create a .php file that contains the code to validate
user input and re-draw the form with a message if the user enters bad input. For your form,
that would mean:
o TO: Your Email Address
o FROM: User’s Email Address
o CC: User’s Email Address (it’s nice to give them a copy of their own email.)
o SUBJECT: (emails must have a subject or get spam filtered.)
o BODY: (Use HTML and/or CSS to format the following):
Category = A value from the drop-down described above.
Message = The main body of the message from the textarea.
Date Sent = The date/time stamp collected above.
If all went well, let the user know in the browser. This might be a handy place to put a
notification window, but you can also simply display a page with a message and a link or
submit button that takes the user back to the initial form or home page.
You should comment your code well. If something is going wrong, neither I nor the grader
will spend a lot of time debugging your work to give you partial credit. Improve your
chances of partial credit by good comments so we can quickly figure out your intent.
Work together to figure things out but, as always, turn in your own code.
Project Report
The final step of this assignment is to create a report consisting of a cover page, an overview of
the project, sample output, and the source code. See Assignment Policies on either the class
website or Bb Learn. Just as a reminder, the cover page should contain the following
information. Correct the date to be the day you actually turn in the project.