Question
This is php class In this exercise, you will create a single PHP file to display and process a form that is a working Contact
This is php class
In this exercise, you will create a single PHP file to display and process a form that is a working Contact Me page. This page will have inputs for the subject, the senders name, the senders e-mail address, and the message. The form will also send a copy of the message to the sender.
All the code required to make a functioning Contact Me PHP script is provided. You are required to type up all the code below. Then add comments into the code ( // or /* .... */) to fully explain it. Each function should be individually explained.
1. Create a new document in your text editor. Type the declaration, element, header information, and
element. The page title should be Contact Me.2. Add the opening and closing tags for the PHP script section in the body of the document:
3. Add a function called validateInput() within the php tag. 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.
4. Add a function called validateEmail() immediately after the validateInput() function. This function is almost exactly like the validateInput() function, but it adds a filter_var() (Links to an external site.)Links to an external site.test to validate that the entered e-mail address is in the correct format.
5. Add a function called displayForm() immediately after the validateEmail() function. This function takes one parameter for each form field and displays the form. It uses the parameters for sticky form functionality.
6. Immediately after the displayForm() function, declare and initialize a set of variables as follows:
7. Next, add the following code to check for and validate the input. Note that $_POST['Email'] is checked with the validateEmail() function instead of the validateInput() function.
8. Next, add a conditional statement that checks the value of $ShowForm. If $ShowForm is TRUE, the form is displayed. Otherwise, an e-mail message is sent and a status message is displayed. Note that a copy is sent to the sender.
php
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started