Web Development Exercise 4-2

In this exercise, you will create an All-in-One form that is a work- ing “Contact Me” page. This page will have inputs for the subject, the sender’s name, the sender’s e-mail address, and the message. The form will also send a copy of the message to the sender. 1. Create a new document in your text editor. Type the !DOCTYPE declaration, element, header information, and element. Use the strict DTD and “Contact Me” as the content of the element. 2. Add the opening and closing tags for the PHP script section in the body of the document: <?php ?>3. Add a function called validateInput(). This function takes two parameters. The first parameter, $data, is a string to be validated. The second parameter, $fieldName, is the name of the form field. The function returns the $data parameter after it has been cleaned up. Notice that the function uses the global variable $errorCount. 225 function validateInput($data, $fieldName) { global $errorCount; if (empty($data)) { echo “”$fieldName”””” is a required field.n””””;


Prof. Angela

4.6/5

Calculate Price


Price (USD)
$
Open chat