André Restivo

PHP Solutions

1. HTTP Parameters

You can also download the complete solution:

sum2.php:

<?php
  $num1 = $_GET['num1'];
  $num2 = $_GET['num2'];
  $sum = $num1 + $num2;
?>
<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <title>Sum Result</title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <p><?=$num1?> + <?=$num1?> = <?=$sum?></p>
    <a href="form2.html">Do another sum.</a>
  </body>
</html>

form2.html:

<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <title>Sum Result</title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <form action="sum2.php" method="get">
      <label>Number 1:
        <input type="number" name="num1" value="0">
      </label>
      <label>Number 2:
        <input type="number" name="num2" value="0">
      </label>      
      <button type="submit">Sum</button>
    </form>
  </body>
</html>

4., 5. and 6. News Page