Question: Write the code that processes the data entered by the user (This is the fierst question) 1. Open the index.php file for this application and

Write the code that processes the data entered by the user (This is the fierst question)

1. Open the index.php file for this application and review the code. Note that it doesnt process the data thats entered into the text boxes.

2. Open the string_tester.php file for this application and review the code. Note that the PHP code that displays the $message variable uses the nl2br function to convert new line characters to tags.

3. Add the code that uses the data thats entered into the text box controls to display a message thats formatted like this:

Hello Joel, Thank you for entering this data:

Name: Joel Murach Email: joel@murach.com Phone: 415-123-4567

When formatting this message, use escape sequences to insert new line characters.

4. Make sure the user enters a name, but only display the first name in the message. For both the complete name and the first name, capitalize the first letter of the name only.

5. Make sure the user enters an email address, and make sure that this address contains at least one @ sign and one dot character (.).

6. Make sure the phone number contains at least seven digits, not including formatting characters such as dashes, spaces, and parenthesis.

7. Test the application to make sure it works correctly.

index.php

//process $action = filter_input(INPUT_POST, 'action');

switch ($action) { case 'process_data': $name = filter_input(INPUT_POST, 'name'); $email = filter_input(INPUT_POST, 'email'); $phone = filter_input(INPUT_POST, 'phone');

/************************************************* * validate and process the name ************************************************/ // 1. make sure the user enters a name // 2. display the name with only the first letter capitalized

/************************************************* * validate and process the email address ************************************************/ // 1. make sure the user enters an email // 2. make sure the email address has at least one @ sign and one dot character

/************************************************* * validate and process the phone number ************************************************/ // 1. make sure the user enters at least seven digits, not including formatting characters // 2. format the phone number like this 123-4567 or this 123-456-7890

/************************************************* * Display the validation message ************************************************/ $message = "This page is under construction. " . "Please write the code that processes the data.";

break; } include 'string_tester.php'; ?>

string_tester.php

String Tester

String Tester

Message:

main.css

body { font-family: Arial, Helvetica, sans-serif; } main { width: 450px; margin: 0 auto; padding: 1em; background: white; border: 2px solid navy; } h1 { margin-top: 0; color: navy; } label { display: block; width: 8em; text-align: right; margin: 0 0 .5em; padding: 0 1em; float: left; } input, select { display: block; float: left; margin-bottom: .5em; margin-top: 0; } br { clear: left; }

. Write the code that processes the data entered by the user (This

The results (assuming the email lacks the @ character) will resemble the image in Figure 2. is the fierst question) 1. Open the index.php file for this application

Add more lines at the end of the message that display the user entries like the example below. (This is the second enhancement question) First Name: Ray Middle Name: Lamar Last Name: Harris Area code: 415 Phone number: 123-4567

Then, test your enhancements by entering appropriate data in the name and phone number boxes.

For example, if the user enters the values below

and review the code. Note that it doesnt process the data thats the result can be seen in the example below. entered into the text boxes. 2. Open the string_tester.php file for this

String Tester Name Phone Number Submit Message: Enter some data and click on the ubit button. Figure 1 String Tester Name Phone Number Submit Message: Enter some data and click on the ubit button. Figure 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!