Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.20 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5. <style>
  6. .error {color: #FF0000;}
  7. </style>
  8. </head>
  9.  
  10. <body>
  11. <?php
  12. $nameErr = $achternaamErr = $emailErr = $LeerlingnrErr = $klasErr = $tellnrErr = "";
  13. $voornaam = $tussenvoegsel = $achternaam = $email = $leerlingnummer = $klas = $course = $telefoonnummer = "";
  14. $ok = true;
  15. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  16. if (empty($_POST["Voornaam"])) {
  17. $nameErr = "Voornaam is verplicht!";
  18. $ok = false;
  19. }else {
  20. $voornaam = test_input ($_POST["Voornaam"]);
  21. }
  22.  
  23.  
  24. if (empty($_POST["tussenvoegsel"])) {
  25. $tussenvoegsel = test_input($_POST["Tussenvoegsel"]);
  26. }
  27.  
  28.  
  29. if (empty($_POST["Achternaam"])) {
  30. $AchternaamErr = "Achternaam is verplicht!";
  31. }else {
  32. $achternaam = test_input($_POST["Achternaam"]);
  33. }
  34.  
  35. if(empty($_POST["email"])) {
  36. $emailErr = "Email is verplicht!";
  37. }else {
  38. $email = test_input($_POST["email"]);
  39.  
  40. if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  41. $emailErr = "verkeerd e-mail formaat";
  42. $ok = false;
  43. }
  44.  
  45. }
  46.  
  47. if (empty($_POST["Leerlingnummer"])) {
  48. $LeerlingnrErr = "Leerlingnummer is verplicht!";
  49. }else {
  50. $leerlingnummer = test_input($_POST["Leerlingnummer"]);
  51.  
  52. }
  53.  
  54. if (empty($_POST["Klas"])) {
  55. $KlasErr = "Klas is verplicht!";
  56. }else {
  57. $Klas = test_input($_POST["Klas"]);
  58. }
  59.  
  60. if (empty($_POST["Telefoonnummer"])) {
  61. $telnrErr = "Telefoonnummer is verplicht!";
  62. }else {
  63. $telefoonnummer = test_input($_POST["Telefoonnummer"]);
  64.  
  65. }
  66. }
  67. function test_input($data) {
  68. $data = trim($data);
  69. $data = stripslashes($data);
  70. $data = htmlspecialchars($data);
  71. return $data;
  72. }
  73. ?>
  74.  
  75. <h2>Regristratie van uw info</h2>
  76.  
  77. <p><span class = "error">* verplicht veld.</span></p>
  78.  
  79. <form method = "POST" action = "<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
  80. <table>
  81. <tr>
  82. <td maxlength="10">Voornaam:</td>
  83. <td><input type = "text" name = "Voornaam" required maxlength="30" value="<?php echo $voornaam;?>">
  84. <span class = "error">* <?php echo $nameErr;?></span>
  85. </td>
  86. </tr>
  87.  
  88. <tr>
  89. <td>Tussenvoegsel:</td>
  90. <td><input type = "text" name = "Tussenvoegsel" maxlength="10" value="<?php echo $tussenvoegsel;?>">
  91. </td>
  92. </tr>
  93.  
  94. <tr>
  95. <td>Achternaam:</td>
  96. <td><input type = "text" name = "Achternaam" required maxlength="30" value="<?php echo $achternaam;?>">
  97. <span class = "error">* <?php echo $AchternaamErr;?></span>
  98. </td>
  99. </tr>
  100.  
  101. <tr>
  102. <td>Leerlingnummer:</td>
  103. <td> <input type = "number" name = "Leerlingnummer" required maxlength="10" value="<?php echo $leerlingnummer;?>">
  104. <span class = "error"><?php echo $websiteErr;?></span>
  105. </td>
  106. </tr>
  107.  
  108. <tr>
  109. <td>Klas:</td>
  110. <td> <input type = "text" name = "Klas" required maxlength="10" value="<?php echo $Klas;?>">
  111. <span class = "error">* <?php echo $KlasErr;?></span>
  112. </td>
  113. </tr>
  114.  
  115. <tr>
  116. <td>Telefoonnummer:</td>
  117. <td> <input type = "number" name = "Telefoonnummer" maxlength="10" value="<?php echo $telefoonnummer;?>">
  118. <span class = "error"><?php echo $websiteErr;?></span>
  119. </td>
  120. </tr>
  121.  
  122. <tr>
  123. <td>E-mail: </td>
  124. <td><input type = "text" name = "email" required maxlength="50" value="<?php echo $email;?>">
  125. <span class = "error">*<?php echo $emailErr;?></span>
  126. </td>
  127. </tr>
  128.  
  129.  
  130. <tr>
  131. <td> Geboortedatum: <br>
  132. <label name="geboortedatum" type="label" name = "geboortedatum" ></label>
  133. <select name="geboortedatum" >
  134.  
  135. <?php
  136. for($i = 1; $i <= 31; $i++)
  137. {
  138.  
  139. echo '<option value="'.$i.'">'.$i.'</option>';
  140. }
  141. ?>
  142. </select>
  143. <select name="geboortedatum2" required>
  144. <?php
  145. for($i = 1; $i <= 12; $i++)
  146. {
  147. echo '<option value="'.$i.'">'.$i.'</option>';
  148. }
  149. ?>
  150. </select>
  151. <select name="geboortedatum3" required>
  152. <?php
  153. for($i = date('Y'); $i >= 1950; $i--)
  154. {
  155. echo '<option value="'.$i.'">'.$i.'</option>';
  156. }
  157. ?>
  158.  
  159. </select>
  160. </td>
  161. </tr>
  162.  
  163.  
  164. <tr>
  165. <td>
  166. <input type = "submit" name = "submit" value = "Submit">
  167. </td>
  168. </tr>
  169.  
  170. </table>
  171.  
  172.  
  173.  
  174. </form>
  175.  
  176. <?php
  177. $spatie = " - ";
  178. if ($ok) {
  179. echo "<h2>Zijn dit je gegevens? :</h2>";
  180. echo ("<p>Je naam is $voornaam $tussenvoegsel $achternaam</p>");
  181. echo ("<p> Je leerlingnummer is $leerlingnummer</p>");
  182. echo ("<p>Je klas is $Klas </p>");
  183. echo ("<p>Je telefoonnummer is $telefoonnummer </p>");
  184. echo ("<p> Je emailadres is $email</p>");
  185. echo "Je geboortedatum:" . $_POST["geboortedatum"] . $spatie . $_POST["geboortedatum2"] . $spatie . $_POST["geboortedatum3"];
  186. $geboortedatum = $_POST["geboortedatum3"] . "-" . $_POST["geboortedatum2"] . "-" . $_POST["geboortedatum"];
  187. for($i = 0; $i < count($subject); $i++) {
  188. echo($subject[$i] . " ");
  189. }
  190. }
  191. ?><br><br><br>
  192. <?php
  193. $servername = "localhost";
  194. $username = "raifex";
  195. $password = "";
  196.  
  197. try {
  198. $conn = new PDO("mysql:host=$servername;dbname=cijferlijst", $username, $password);
  199. // set the PDO error mode to exception
  200. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  201. echo "Connected successfully";
  202. }
  203. catch(PDOException $e)
  204. {
  205. echo "Connection failed: " . $e->getMessage();
  206. }
  207. $sql = "Insert into leerling
  208. (Leerlingnummer, Voornaam, Tussenvoegsel, Achternaam, Klas, Telefoonnummer, Emailadres, Geboortedatum)
  209. VALUES ('$leerlingnummer','$voornaam','$tussenvoegsel','$achternaam','$Klas', '$telefoonnummer', '$email','$geboortedatum')";
  210.  
  211. $conn->exec($sql);
  212. ?>
  213. </body>
  214. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement