Advertisement
YavorGrancharov

Product of 3 Numbers

Dec 2nd, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.01 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>First Steps Into PHP</title>
  6.  
  7. </head>
  8. <body>
  9. <form>
  10.     X: <input type="text" name="num1" />
  11.     Y: <input type="text" name="num2" />
  12.     Z: <input type="text" name="num3" />
  13.     <input type="submit" />
  14. </form>
  15. <?php
  16.     if (isset($_GET['num1']) && isset($_GET['num2']) && isset($_GET['num3'])) {
  17.         $num1 = intval($_GET['num1']);
  18.         $num2 = intval($_GET['num2']);
  19.         $num3 = intval($_GET['num3']);
  20.         $count = 0;
  21.         if ($num1 == 0 || $num2 == 0 || $num3 == 0) {
  22.             echo "Positive";
  23.         }
  24.         else {
  25.             if ($num1 < 0) {
  26.                 $count++;
  27.             }
  28.             if ($num2 < 0) {
  29.                 $count++;
  30.             }
  31.             if ($num3 < 0) {
  32.                 $count++;
  33.             }
  34.             if ($count % 2 == 0) {
  35.                 echo "Positive";
  36.             } else {
  37.                 echo "Negative";
  38.             }
  39.         }
  40.     }
  41. ?>
  42. </body>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement