Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.05 KB | None | 0 0
  1. <?php
  2.     if (isset($_POST['verzenden'])) {
  3.         (empty($_POST['voornaam'])
  4.             ? $errors[] = 'Je hebt de voornaam niet ingevuld'
  5.             : $voornaam = $_POST['voornaam']); 
  6.         (empty($_POST['achternaam'])
  7.             ? $errors[] = 'Je hebt de achternaam niet ingevuld'
  8.             : $achternaam = $_POST['achternaam']); 
  9.         (empty($_POST['leeftijd'])
  10.             ? $errors[] = 'Je hebt de leeftijd niet ingevuld'
  11.             : (in_array($_POST['leeftijd'], range(0,150)))
  12.                 ? $leeftijd = $_POST['leeftijd']
  13.                 : $errors[] = 'Leeftijd is onREAlistisch');
  14.         (empty($_POST['datum'])
  15.             ? $errors[] = 'Je hebt de datum niet ingevuld'
  16.             : $datum = $_POST['datum']);   
  17.     }
  18. ?>
  19. <!DOCTYPE html>
  20. <html lang="en">
  21. <head>
  22.     <meta charset="UTF-8">
  23.     <title>Opdracht3</title>
  24.     <style>
  25.         input {
  26.             display: block;
  27.         }
  28.         .red {
  29.             color: rbga(255,255,0,.1);
  30.         }
  31.     </style>
  32.     </head>
  33.     <body>
  34.         <h1>Skrrrttt boem</h1>
  35.         <form action="opdracht3.php" method="post">
  36.             <label for="voornaam">Naam</label>
  37.             <input type="text" id="voornaam" name="voornaam"
  38.                 <?php if(isset($voornaam)){ echo 'value="'.$voornaam.'"';} ?>>
  39.             <label for="achternaam">achternaam</label>
  40.             <input type="text" id="achternaam" name="achternaam"
  41.                 <?php if(isset($achternaam)){ echo 'value="'.$achternaam.'"';} ?>>
  42.             <label for="leeftijd">leeftijd</label>
  43.             <input type="number" id="leeftijd" name="leeftijd"
  44.                 <?php if(isset($leeftijd)){ echo 'value="'.$leeftijd.'"';} ?>>
  45.             <label for="datum">datum</label>
  46.             <input type="date" id="datum" name="datum"
  47.                 <?php if(isset($datum)){ echo 'value="'.$datum.'"';} ?>>
  48.             <input type="submit" name="verzenden">
  49.             <input type="reset">
  50.         </form>
  51.         <?php
  52.             debug($errors);
  53.             if (isset($_POST['verzenden'])) {
  54.                 if (count($errors)>0){
  55.                     foreach ($errors as $error) {
  56.                         echo '<p class="red">' . $error . '</p>';
  57.                     }
  58.                 } else {
  59.                     echo '<p>' . 'Je naam is' . $voornaam . ' ' . $achternaam . '</p>';
  60.                     echo '<p>' . 'Je leeftijd is' . $leeftijd . '</p>';
  61.                     echo '<p>' . 'Je datum is' . $datum . '</p>';              
  62.                 }
  63.             }
  64.          ?>
  65.     </body>
  66. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement