1. Start the Chrome browser and run the application in the ex_starts/ch09_ex2 directory. This should display a page that allows you to enter three numbers and provides starting values for the three...

1 answer below »

1. Start the Chrome browser and run the application in the ex_starts/ch09_ex2 directory. This should display a page that allows you to enter three numbers and provides starting values for the three numbers.


2. Click on the Submit button. Note that this displays a message that includes the values of the three numbers but doesn’t include the values for the rest of the message.



Write the code that processes the data entered by the user


3. Open the index.php file for this application and review the code. Note that it doesn’t process the data. Instead, it just displays the data on the form.


4. Open the number_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 newline characters to


tags.


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



Number 1: 78



Number 2: -105.33



Number 3: 0.0049






Number 2 ceiling: -105



Number 2 floor: -106



Number 3 rounded: 0.005






Min: -105.33



Max: 78






Random: 86


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


6. Make sure the user enters all three numbers and that these numbers are valid.


7. Make sure the rounded number is rounded to 3 decimal places.


8. Make sure a random number is a number between 1 and 100.


Test the application to make sure it works correctly with the default values and also with other values
the required projects to modify will be provided upon request
Answered Same DayJun 23, 2021

Answer To: 1. Start the Chrome browser and run the application in the ex_starts/ch09_ex2 directory. This should...

Sanghamitra answered on Jun 27 2021
147 Votes
61038/ex_starts/ch09_ex2/index.php
//set default values
$number1 = 78;
$number2 = -105.33;

$number3 = 0.0049;
$message = 'Enter some numbers and click on the Submit button.';
//process
$action = filter_input(INPUT_POST, 'action');
switch ($action) {
case 'process_data':
$number1 = filter_input(INPUT_POST, 'number1');
$number2 = filter_input(INPUT_POST, 'number2');
$number3 = filter_input(INPUT_POST, 'number3');
// make sure the user enters three numbers
if(!empty($number1) && !empty($number2) && !empty($number3))
        {
            
// make sure the numbers are valid
         if(is_numeric($number1) && is_numeric($number2) && is_numeric($number3))
         {
                // get the ceiling for $number2
$number2_ceil =ceil($number2);
                
                // get the floor for $number2
$number2_floor =floor($number2);
                
                // round $number3 to 3 decimal places
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here