MilanLucas / educom-webshop-basis-1707216396

0 stars 0 forks source link

03-B: Opdracht 1.3: Server-side verwerking van een formulierdata #5

Open JeroenHeemskerk opened 9 months ago

JeroenHeemskerk commented 9 months ago

 

 

Mocht je er niet uitkomen, globaal ziet je contact.php er alsvolgt uit:

<doctype HTML>
<html>
<head>...</head>
<body>
<?php

   // initate the variables
   $name = $email = ... = $message = '';
   $nameErr = $emailErr = ... = $messageErr = '';
   $valid = false;


   if ($_SERVER['REQUEST_METHOD'] == 'POST') {
      // validate the 'POST' data

      // ....   

      $valid = ...
   }
  ?>

  <header>
  <h1>Contact</h1>
  </header>

  <nav>
  <ul class='menu'> ... </ul>
  </nav>

  <section>;

    <?php if (!$valid) { /* Show the next part only when $valid is false */ ?>

      <form method="POST" action="contact.php">;
        ...
        <input name="email" value="<?php echo $email; ?>" id="email">
        <span class="error">* <?php echo $emailErr; ?></span>
        ...
      </form>;

    <?php } else { /* Show the next part only when $valid is true */ ?>

     <p>Bedankt voor uw reactie:</p>
     ...
     <div>Email: <?php echo $email; ?></div>
     ...     

    <?php } /* End of conditional showing */ ?>

  </section>

  <footer> .... </footer>
</body>