Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- .error {color: #FF0000;}
- </style>
- </head>
- <body>
- <?php
- $nameErr = $achternaamErr = $emailErr = $LeerlingnrErr = $klasErr = $tellnrErr = "";
- $voornaam = $tussenvoegsel = $achternaam = $email = $leerlingnummer = $klas = $course = $telefoonnummer = "";
- $ok = true;
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["Voornaam"])) {
- $nameErr = "Voornaam is verplicht!";
- $ok = false;
- }else {
- $voornaam = test_input ($_POST["Voornaam"]);
- }
- if (empty($_POST["tussenvoegsel"])) {
- $tussenvoegsel = test_input($_POST["Tussenvoegsel"]);
- }
- if (empty($_POST["Achternaam"])) {
- $AchternaamErr = "Achternaam is verplicht!";
- }else {
- $achternaam = test_input($_POST["Achternaam"]);
- }
- if(empty($_POST["email"])) {
- $emailErr = "Email is verplicht!";
- }else {
- $email = test_input($_POST["email"]);
- if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
- $emailErr = "verkeerd e-mail formaat";
- $ok = false;
- }
- }
- if (empty($_POST["Leerlingnummer"])) {
- $LeerlingnrErr = "Leerlingnummer is verplicht!";
- }else {
- $leerlingnummer = test_input($_POST["Leerlingnummer"]);
- }
- if (empty($_POST["Klas"])) {
- $KlasErr = "Klas is verplicht!";
- }else {
- $Klas = test_input($_POST["Klas"]);
- }
- if (empty($_POST["Telefoonnummer"])) {
- $telnrErr = "Telefoonnummer is verplicht!";
- }else {
- $telefoonnummer = test_input($_POST["Telefoonnummer"]);
- }
- }
- function test_input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- ?>
- <h2>Regristratie van uw info</h2>
- <p><span class = "error">* verplicht veld.</span></p>
- <form method = "POST" action = "<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
- <table>
- <tr>
- <td maxlength="10">Voornaam:</td>
- <td><input type = "text" name = "Voornaam" required maxlength="30" value="<?php echo $voornaam;?>">
- <span class = "error">* <?php echo $nameErr;?></span>
- </td>
- </tr>
- <tr>
- <td>Tussenvoegsel:</td>
- <td><input type = "text" name = "Tussenvoegsel" maxlength="10" value="<?php echo $tussenvoegsel;?>">
- </td>
- </tr>
- <tr>
- <td>Achternaam:</td>
- <td><input type = "text" name = "Achternaam" required maxlength="30" value="<?php echo $achternaam;?>">
- <span class = "error">* <?php echo $AchternaamErr;?></span>
- </td>
- </tr>
- <tr>
- <td>Leerlingnummer:</td>
- <td> <input type = "number" name = "Leerlingnummer" required maxlength="10" value="<?php echo $leerlingnummer;?>">
- <span class = "error"><?php echo $websiteErr;?></span>
- </td>
- </tr>
- <tr>
- <td>Klas:</td>
- <td> <input type = "text" name = "Klas" required maxlength="10" value="<?php echo $Klas;?>">
- <span class = "error">* <?php echo $KlasErr;?></span>
- </td>
- </tr>
- <tr>
- <td>Telefoonnummer:</td>
- <td> <input type = "number" name = "Telefoonnummer" maxlength="10" value="<?php echo $telefoonnummer;?>">
- <span class = "error"><?php echo $websiteErr;?></span>
- </td>
- </tr>
- <tr>
- <td>E-mail: </td>
- <td><input type = "text" name = "email" required maxlength="50" value="<?php echo $email;?>">
- <span class = "error">*<?php echo $emailErr;?></span>
- </td>
- </tr>
- <tr>
- <td> Geboortedatum: <br>
- <label name="geboortedatum" type="label" name = "geboortedatum" ></label>
- <select name="geboortedatum" >
- <?php
- for($i = 1; $i <= 31; $i++)
- {
- echo '<option value="'.$i.'">'.$i.'</option>';
- }
- ?>
- </select>
- <select name="geboortedatum2" required>
- <?php
- for($i = 1; $i <= 12; $i++)
- {
- echo '<option value="'.$i.'">'.$i.'</option>';
- }
- ?>
- </select>
- <select name="geboortedatum3" required>
- <?php
- for($i = date('Y'); $i >= 1950; $i--)
- {
- echo '<option value="'.$i.'">'.$i.'</option>';
- }
- ?>
- </select>
- </td>
- </tr>
- <tr>
- <td>
- <input type = "submit" name = "submit" value = "Submit">
- </td>
- </tr>
- </table>
- </form>
- <?php
- $spatie = " - ";
- if ($ok) {
- echo "<h2>Zijn dit je gegevens? :</h2>";
- echo ("<p>Je naam is $voornaam $tussenvoegsel $achternaam</p>");
- echo ("<p> Je leerlingnummer is $leerlingnummer</p>");
- echo ("<p>Je klas is $Klas </p>");
- echo ("<p>Je telefoonnummer is $telefoonnummer </p>");
- echo ("<p> Je emailadres is $email</p>");
- echo "Je geboortedatum:" . $_POST["geboortedatum"] . $spatie . $_POST["geboortedatum2"] . $spatie . $_POST["geboortedatum3"];
- $geboortedatum = $_POST["geboortedatum3"] . "-" . $_POST["geboortedatum2"] . "-" . $_POST["geboortedatum"];
- for($i = 0; $i < count($subject); $i++) {
- echo($subject[$i] . " ");
- }
- }
- ?><br><br><br>
- <?php
- $servername = "localhost";
- $username = "raifex";
- $password = "";
- try {
- $conn = new PDO("mysql:host=$servername;dbname=cijferlijst", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- echo "Connected successfully";
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- $sql = "Insert into leerling
- (Leerlingnummer, Voornaam, Tussenvoegsel, Achternaam, Klas, Telefoonnummer, Emailadres, Geboortedatum)
- VALUES ('$leerlingnummer','$voornaam','$tussenvoegsel','$achternaam','$Klas', '$telefoonnummer', '$email','$geboortedatum')";
- $conn->exec($sql);
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement