Advertisement
Guest User

Untitled

a guest
Nov 8th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.12 KB | None | 0 0
  1. <?php
  2. require ("../php/testinput.php");
  3. require ("../php/database.php");
  4. $ok=true;
  5.  
  6. $nameErr = $achternaamErr = $straatnaamErr = $postcodeErr = $woonplaatsErr = $huisnummer = $emailErr = $geslachtErr = "";
  7. $voornaam = $tussenvoegsel = $achternaam = $geboortedatum = $geslacht = $straatnaam = $huisnummer = $toevoeging = $postcode = $woonplaats = $email = $telefoonnummer = $gebruikersnaam = $wachtwoord = "";
  8. $rol = "gebruiker";
  9.  
  10. if ($_SERVER["REQUEST_METHOD"] == "POST") {
  11. if (empty($_POST["voornaam"])) {
  12. $nameErr = "Voornaam is verplicht!";
  13. $ok=false;
  14. }else {
  15. $voornaam = test_input($_POST["voornaam"]);
  16. }
  17.  
  18. if (isset($_POST["tussenvoegsel"])) {
  19. $tussenvoegsel = test_input($_POST["tussenvoegsel"]);
  20. }
  21.  
  22. if (empty($_POST["achternaam"])) {
  23. $achternaamErr = "Achternaam is verplicht!";
  24. $ok=false;
  25. }else {
  26. $achternaam = test_input($_POST["achternaam"]);
  27. }
  28.  
  29. if (empty($_POST["straatnaam"])) {
  30. $straatnaamErr = "Straatnaam is verplicht!";
  31. $ok=false;
  32. }else {
  33. $straatnaam = test_input($_POST["straatnaam"]);
  34. }
  35.  
  36. if (empty($_POST["huisnummer"])) {
  37. $huisnummerErr = "Huisnummer is verplicht!";
  38. $ok=false;
  39. }else {
  40. $huisnummer = test_input($_POST["huisnummer"]);
  41. }
  42.  
  43. if (empty($_POST["toevoeging"])) {
  44. $toevoegingErr = "Toevoeging is verplicht!";
  45. }else {
  46. $toevoeging = test_input($_POST["toevoeging"]);
  47. }
  48.  
  49. if (empty($_POST["postcode"])) {
  50. $postcodeErr = "Postcode is verplicht!";
  51. $ok=false;
  52. }else {
  53. $postcode = test_input($_POST["postcode"]);
  54. }
  55.  
  56. if (empty($_POST["woonplaats"])) {
  57. $woonplaatsErr = "Woonplaats is verplicht!";
  58. $ok=false;
  59. }else {
  60. $woonplaats = test_input($_POST["woonplaats"]);
  61. }
  62.  
  63. if (empty($_POST["email"])) {
  64. $emailErr = "Email is verplicht!";
  65. $ok=false;
  66. }else {
  67. $email = test_input($_POST["email"]);
  68.  
  69. if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  70. $emailErr = "verkeerd e-mail formaat";
  71. }
  72. }
  73.  
  74. if (empty($_POST["telefoonnummer"])) {
  75. }else {
  76. $telefoonnummer = test_input($_POST["telefoonnummer"]);
  77. }
  78.  
  79. if (empty($_POST["gebruikersnaam"])) {
  80. $gebruikersnaamErr = "Gebruikersnaam is verplicht!";
  81. $ok=false;
  82. }else {
  83. $gebruikersnaam = test_input($_POST["gebruikersnaam"]);
  84. }
  85.  
  86. if (empty($_POST["wachtwoord"])) {
  87. $wachtwoordErr = "Wachtwoord is verplicht!";
  88. $ok=false;
  89. }else {
  90. $wachtwoord = test_input($_POST["wachtwoord"]);
  91. }
  92. if (empty($_POST["geslacht"])){
  93. $geslachtErr = "Geslacht is verplicht!";
  94. }else{
  95. $geslacht = test_input($_POST['geslacht']);
  96. }
  97.  
  98. }
  99. ?>
  100.  
  101. <p class = "h2">Registratie van uw info</p><br>
  102.  
  103. <p><span class = "error">* verplicht veld.</span></p>
  104.  
  105. <form method = "POST" action = "<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
  106. <table>
  107. <tr>
  108. <td>Gebruikersnaam:</td>
  109. <td><input type = "text" name = "gebruikersnaam"required maxlength="30" value="<?php echo $gebruikersnaam;?>">
  110. <span class = "error">* <?php echo $gebruikersnaamErr;?></span>
  111. </td>
  112. </tr>
  113. <tr>
  114. <td>Wachtwoord:</td>
  115. <td><input type = "password" name = "wachtwoord"required maxlength="30" value="<?php echo $wachtwoord;?>">
  116. <span class = "error">* <?php echo $wachtwoordErr;?></span>
  117. </td>
  118. </tr>
  119. <tr>
  120. <td>Voornaam:</td>
  121. <td><input type = "text" name = "voornaam"required maxlength="30" value="<?php echo $voornaam;?>">
  122. <span class = "error">* <?php echo $nameErr;?></span>
  123. </td>
  124. </tr>
  125.  
  126. <tr>
  127. <td>Tussenvoegsel:</td>
  128. <td><input type = "text" name = "tussenvoegsel"maxlength="10" value="<?php echo $tussenvoegsel;?>">
  129. </td>
  130. </tr>
  131.  
  132. <tr>
  133. <td>Achternaam:</td>
  134. <td><input type = "text" name = "achternaam"required maxlength="30" value="<?php echo $achternaam;?>">
  135. <span class = "error">*<?php echo $AchternaamErr;?></span>
  136. </td>
  137. </tr>
  138.  
  139. <tr>
  140. <td>Straatnaam:</td>
  141. <td> <input type = "text" name = "straatnaam"required maxlength="30" value="<?php echo $straatnaam;?>">
  142. <span class = "error">*<?php echo $straatnaamErr;?></span>
  143. </td>
  144. </tr>
  145. <tr>
  146. <td>Huisnummer:</td>
  147. <td> <input type = "number" name = "huisnummer" required maxlength="10" value="<?php echo $huisnummer;?>">
  148. <span class = "error">*<?php echo $huisnummerErr;?></span>
  149. </td>
  150. </tr>
  151. <tr>
  152. <td>Toevoeging:</td>
  153. <td> <input type = "text" name = "toevoeging"maxlength="10" value="<?php echo $toevoeging;?>">
  154. </td>
  155. </tr>
  156. <tr>
  157. <td>Postcode:</td>
  158. <td> <input type = "text" name = "postcode"required maxlength="6" value="<?php echo $postcode;?>">
  159. <span class = "error">*<?php echo $postcodeErr;?></span>
  160. </td>
  161. </tr>
  162. <tr>
  163. <td>Woonplaats:</td>
  164. <td> <input type = "text" name = "woonplaats" required maxlength="50" value="<?php echo $woonplaats;?>">
  165. <span class = "error">*<?php echo $woonplaatsErr;?></span>
  166. </td>
  167. </tr>
  168. <tr>
  169. <td>E-mail: </td>
  170. <td><input type = "text" name = "email" required maxlength="50" value="<?php echo $email;?>">
  171. <span class = "error">*<?php echo $emailErr;?></span>
  172. </td>
  173. </tr>
  174. <tr>
  175. <td>Telefoonnummer:</td>
  176. <td> <input type = "number" name = "telefoonnummer" maxlength="10" value="<?php echo $telefoonnummer;?>">
  177. <span class = "error"><?php echo $telefoonnummerErr;?></span>
  178. </td>
  179. </tr>
  180. <tr>
  181. <td>Geslacht:</td>
  182. <td><input type="radio" name="geslacht" value="vrouw">Vrouw
  183. <input type="radio" name = "geslacht" value ="man">Man
  184. <span class="error">*<?php echo $geslachtErr;?></span>
  185. </td>
  186. </tr>
  187. <tr>
  188. <td> Geboortedatum:</td>
  189. <td>
  190. <label name="geboortedatum" type="label" name = "geboortedatum"></label>
  191. <select name="geboortedatum">
  192. <?php
  193. for($i = 1; $i <= 31; $i++)
  194. {
  195. echo '<option value="'.$i.'">'.$i.'</option>';
  196. }
  197. ?>
  198. </select>
  199. <select name="geboortedatum2">
  200. <?php
  201. for($i = 1; $i <= 12; $i++)
  202. {
  203. echo '<option value="'.$i.'">'.$i.'</option>';
  204. }
  205. ?>
  206. </select>
  207. <select name="geboortedatum3">
  208. <?php
  209. for($i = date('Y'); $i >= 1950; $i--)
  210. {
  211. echo '<option value="'.$i.'">'.$i.'</option>';
  212. }
  213. ?>
  214. </select>
  215. </tr>
  216. <tr>
  217. <td></td>
  218. <td><input type = "submit" name = "submit" value = "Verzend"></td>
  219. </tr>
  220. </table>
  221. </form>
  222. <?php
  223. $spatie = " - ";
  224. if (isset($_POST["submit"])) {
  225. if ($ok) {
  226. // echo "<h2>Je gegevens zijn :</h2>";
  227. // echo ("<p> Je gebruikersnaam is $gebruikersnaam</p>");
  228. // echo ("<p> Je wachtwoord is $wachtwoord</p>");
  229. // echo ("<p> Je naam is $voornaam $tussenvoegsel $achternaam </p>");
  230. // echo ("<p> Je geslacht is $geslacht</p>");
  231. // echo ("<p> Je adres is $straatnaam $huisnummer $toevoeging</p>");
  232. // echo ("<p> Je postcode is $postcode</p>");
  233. // echo ("<p> Je woonplaats is $woonplaats</p>");
  234. // echo ("<p> Je telefoonnummer is $telefoonnummer </p>");
  235. // echo ("<p> Je emailadres is $email</p>");
  236. // echo "uw geboortedatum:" . $_POST["geboortedatum"] . $spatie . $_POST["geboortedatum2"] . $spatie . $_POST["geboortedatum3"];
  237. $geboortedatum = $_POST["geboortedatum3"] . "-" . $_POST["geboortedatum2"] . "-" . $_POST["geboortedatum"];
  238.  
  239. for($i = 0; $i < count($subject); $i++) {
  240. echo($subject[$i] . " ");
  241. }
  242.  
  243. $sql = "INSERT INTO accounts ( voornaam, tussenvoegsel, achternaam, geboortedatum, geslacht, straatnaam, huisnummer, toevoeging, postcode, woonplaats, emailadres, telefoonnummer, gebruikersnaam, wachtwoord, rol)
  244. VALUES ('$voornaam', '$tussenvoegsel', '$achternaam','$geboortedatum', '$geslacht','$straatnaam', '$huisnummer', '$toevoeging','$postcode', '$woonplaats', '$email', '$telefoonnummer','$gebruikersnaam', '$wachtwoord', '$rol')";
  245. // echo $sql;
  246. $conn->exec($sql);
  247. $_SESSION["gebruikersnaam"] = $gebruikersnaam;
  248. $conn = null;
  249. }
  250. }
  251. ?>
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258. <?php
  259. $servername = "localhost";
  260. $username = 'wingfunglam';
  261. $password = "";
  262. $database = "burgerschapwebsite";
  263.  
  264. $conn = new PDO("mysql:host=$servername; dbname=$database", $username, $password);
  265. // $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  266. if ($conn->connect_error) {
  267. die("Connection failed: " . $conn->connect_error);
  268. }
  269. // echo "Connected successfully";
  270. ?>
  271.  
  272.  
  273. <?php
  274.  
  275. function test_input($data) {
  276. $data = trim($data); //verwijdert spaties
  277. $data = stripslashes($data); // verwijdert \
  278. $data = htmlspecialchars($data); //vervangt speciale karakters
  279. return $data;
  280. }
  281. ?>
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288. /*---------------------verplichte meldingen---------------------------*/
  289. .error {color: #FF0000;}
  290. .body {background-color: #0404B4; }
  291. /*---------------------button opmaak----------------------------------*/
  292. /*contact form css */
  293. /* Style inputs with type="text", select elements and textareas */
  294. input[type=text],input[type=password], select{
  295. width: 90%;
  296. padding: 12px 20px;
  297. margin: 8px 0;
  298. box-sizing: border-box;
  299. border: none;
  300. background-color: #3CBC8D;
  301. color: white;
  302. }
  303.  
  304. input[type=number] {
  305. width: 15%; /* Full width */
  306. padding: 12px; /* Some padding */
  307. border: 1px solid #ccc; /* Gray border */
  308. border-radius: 4px; /* Rounded borders */
  309. box-sizing: border-box; /* Make sure that padding and width stays in place */
  310. margin-top: 6px; /* Add a top margin */
  311. margin-bottom: 16px; /* Bottom margin */
  312. resize: vertical; /* Allow the user to vertically resize the textarea (not horizontally) */
  313. background-color: #3CBC8D;
  314. color: white;
  315. }
  316.  
  317. input[name=telefoonnummer] {
  318. width: 90%; /* Full width */
  319. padding: 12px; /* Some padding */
  320. border: 1px solid #ccc; /* Gray border */
  321. border-radius: 4px; /* Rounded borders */
  322. box-sizing: border-box; /* Make sure that padding and width stays in place */
  323. margin-top: 6px; /* Add a top margin */
  324. margin-bottom: 16px; /* Bottom margin */
  325. resize: vertical; /* Allow the user to vertically resize the textarea (not horizontally) */
  326. background-color: #3CBC8D;
  327. color: white;
  328. }
  329. input[type=submit] {
  330. background-color: #8f36be;
  331. color: white;
  332. margin-left: 510px;
  333. padding: 12px 20px;
  334. border: none;
  335. border-radius: 4px;
  336. cursor: pointer;
  337. }
  338.  
  339. /*When moving the mouse over the submit button, add a darker green color */
  340. input[name=verzend]:hover {
  341. background-color: #55379a;
  342. }
  343.  
  344. /* Add a background color and some padding around the form */
  345. /*-----geboortedatum selectie-----------------------------------------*/
  346. input[name=geboortedatum]{
  347. margin-left: 510px;
  348. }
  349. input[name=geboortedatum], input[name=geboortedatum2]{
  350. width: 40px;
  351. }
  352. select{
  353. width: 120px;
  354. margin-left: 5px;
  355. }
  356. /*-------------background aanmeld image-------------------------------*/
  357. .index-bgImgAanmelden {
  358. /*height: 940px;*/
  359. height: 500px;
  360. width: 980px;
  361. /*width: 940px;*/
  362. background-image: url('../images/11.jpg');
  363. background-repeat: no-repeat;
  364. -webkit-filter: blur(5px);
  365. filter: blur(5px)
  366. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement