1. HTTP Parameters

See code below or download the complete solution here.

  • 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><?php echo $num1 ?> + <?php echo $num1 ?> = <?php echo $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>Sum</button>
          </form>
        </body>
      </html>
    

4. News Page – Complete Page

Download solution

5. News Page – Data Layer

Download solution

6. News Page – Presentation Layer

Download solution

 


Acknowledgement

Exercises by André Restivo.