Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['verzenden'])) {
- (empty($_POST['voornaam'])
- ? $errors[] = 'Je hebt de voornaam niet ingevuld'
- : $voornaam = $_POST['voornaam']);
- (empty($_POST['achternaam'])
- ? $errors[] = 'Je hebt de achternaam niet ingevuld'
- : $achternaam = $_POST['achternaam']);
- (empty($_POST['leeftijd'])
- ? $errors[] = 'Je hebt de leeftijd niet ingevuld'
- : (in_array($_POST['leeftijd'], range(0,150)))
- ? $leeftijd = $_POST['leeftijd']
- : $errors[] = 'Leeftijd is onREAlistisch');
- (empty($_POST['datum'])
- ? $errors[] = 'Je hebt de datum niet ingevuld'
- : $datum = $_POST['datum']);
- }
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Opdracht3</title>
- <style>
- input {
- display: block;
- }
- .red {
- color: rbga(255,255,0,.1);
- }
- </style>
- </head>
- <body>
- <h1>Skrrrttt boem</h1>
- <form action="opdracht3.php" method="post">
- <label for="voornaam">Naam</label>
- <input type="text" id="voornaam" name="voornaam"
- <?php if(isset($voornaam)){ echo 'value="'.$voornaam.'"';} ?>>
- <label for="achternaam">achternaam</label>
- <input type="text" id="achternaam" name="achternaam"
- <?php if(isset($achternaam)){ echo 'value="'.$achternaam.'"';} ?>>
- <label for="leeftijd">leeftijd</label>
- <input type="number" id="leeftijd" name="leeftijd"
- <?php if(isset($leeftijd)){ echo 'value="'.$leeftijd.'"';} ?>>
- <label for="datum">datum</label>
- <input type="date" id="datum" name="datum"
- <?php if(isset($datum)){ echo 'value="'.$datum.'"';} ?>>
- <input type="submit" name="verzenden">
- <input type="reset">
- </form>
- <?php
- debug($errors);
- if (isset($_POST['verzenden'])) {
- if (count($errors)>0){
- foreach ($errors as $error) {
- echo '<p class="red">' . $error . '</p>';
- }
- } else {
- echo '<p>' . 'Je naam is' . $voornaam . ' ' . $achternaam . '</p>';
- echo '<p>' . 'Je leeftijd is' . $leeftijd . '</p>';
- echo '<p>' . 'Je datum is' . $datum . '</p>';
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement