Advertisement
ralka

PHP - Sum Two Numbers

Jun 28th, 2016
68
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Document</title>
  6. </head>
  7. <body>
  8. <?php if (isset($_GET['firstNumber']) &&
  9.     isset($_GET['secondNumber'])) {
  10.     $num1 = intval($_GET['firstNumber']);
  11.     $num2 = intval($_GET['secondNumber']);
  12.     $sum = $num1 + $num2;
  13.  
  14.     echo "$num1 + $num2 = $sum";
  15. }
  16. ?>
  17.     <form>
  18.         <div>First Number:</div>
  19.         <input type="number" name="firstNumber"/>
  20.         <div>Second Number:</div>
  21.         <input type="number" name="secondNumber"/>
  22.         <div><input type="submit" value="Submit"/></div>
  23.     </form>
  24. </body>
  25. </html>
Advertisement
RAW Paste Data Copied
Advertisement