PHP Solutions

Chapter 5

The theme of this chapter is forms. Everything will occur on the "Contact Us" page of the Japan Journey site.

Note: I have removed my email address from these exercises, if you wish to contact me, please do so on my about page.

Solution Index

PHP Solutions 5-1
Eliminating magic quotes
This already worked on my server, but the function to call is nukeMagicQuotes(). There's some dummy text to show if it was/wasn't working.
PHP Solutions 5-2
Sending email from the feedback form.
Using the mail() function to send the information in the name, email, and comments fields.
PHP Solutions 5-3
Checking required fields
This works by creating an array of expected items (from the id's of the inputs) and another for required items. If any of the required items aren't filled out, they go into yet another array. As long as that last array is empty, the logic is carried out and the mail is sent. If the array isn't empty, then the mail isn't sent and the user is alerted to the omissions.
PHP Solutions 5-4
Creating sticky form fields
If the mail isn't sent for whatever reason, the information is still in the fields, instead of disappearing.
PHP Solutions 5-5
Blocking emails that contain specific phrases
The phrases are "Content-Type", "BCC:", and "CC:"
PHP Solutions 5-6
Automating the reply address
When the "Submit" button has been a pressed and the resulting email recieved, the "Reply" function in the email client will respond to the email entered in the "Email" field and not the address of the web server.
PHP Solutions 5-7
Getting data from radio button groups
PHP Solutions 5-8
Getting data from check boxes
This uses the implode() function to separate each selected item with commas in the sent email.
PHP Solutions 5-9
Getting data from a drop-down menu
PHP Solutions 5-10
Getting data from a multiple-choice list