3
05/11/2024 8:31 am
Topic starter
You are given a number num1 and a number num2.
Write a PHP script that:
- Multiplies num1 * num2 if num2 is greater than or equal to num1.
- Divides num1 / num2 if num1 is greater than num2.
The input comes as parameters named num1 and num2. Print the output in the HTML page.
Examples:
1 Answer
2
05/11/2024 8:32 am
Here is the code:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> </head> <body> <form> N: <input type="text" name="num1"/> M: <input type="text" name="num2"/> <input type="submit"/> </form> <?php if (isset($_GET['num1']) && isset($_GET['num2'])) { $num1 = $_GET['num1']; $num2 = $_GET['num2']; if ($num2 >= $num1) { echo $num1 * $num2; } else if ($num1 >= $num2) { echo $num1 / $num2; } } ?> </body> </html>