Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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:

image text in transcribed

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.

image text in transcribed

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.

image text in transcribed

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.

image text in transcribed

6. Immediately after the displayForm() function, declare and initialize a set of variables as follows:

image text in transcribed

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.

image text in transcribed

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.

image text in transcribed

9. Save the document as ContactForm.php.

10. Open ContactForm.php by entering the following URL: http://localhost/ContactForm.php.

Verify that the form validates the input fields correctly, redisplays the sticky form when there are errors, and attempts to send the e-mail message when there are no errors. (Not required to actually sent a validate email).

php

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions