Question: when we didn't type amount it shows message I couldn't type..could you give run the code with htmi and php Simple HTML Form label {

when we didn't type amount it shows message I couldn't type..could you give run the code with htmi and php

when we didn't type amount it shows message I couldn't type..could you

Simple HTML Form

label {

font-weight: bold;

color: #300acc;

}

Adder


Enter the numbers you would like to add:

Number 1:

Number 2:

// This is the code which we have added

// We will check for num1 & num2 index if present in the Superglobal variable $_POST

// If both are available we will print the sum upon clicking submit

if (array_key_exists('num1', $_POST) && array_key_exists('num2', $_POST)) {

$a = $_POST['num1'];

$b = $_POST['num2'];

$c = $a + $b;

echo $a . " + " . $b . " = " . $c;

}

/ Validate the number1: if (!empty($_REQUEST['num1'])) { $a = $_REQUEST['num1']; } else { $a= NULL; echo '

enter the 1st numer!

'; } // Validate the number2: if (!empty($_REQUEST['num1'])) { $b= $_REQUEST['num2']; } else { $b = NULL; echo '

enter the 2nd numer!

'; }

?>

Adder of two num Enter number 1 0 Enter number2 0 I submit 9 + 8 = 17

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!