Question: PHP 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
PHP
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
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
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.
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.
Make sure the user enters an email address, and make sure that this address contains at least one @ sign and one dot character (.).
Make sure the phone number contains at least seven digits, not including formatting characters such as dashes, spaces, and parentheses.
string_tester.php file:
String Tester
String Tester
Name: value="">
E-Mail: value="">
Phone Number: value="">
Message:
index.php file:
//set default values $name = ''; $email = ''; $phone = ''; $message = 'Enter some data and click on the Submit button.';
//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'; ?>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
