Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. `<!doctype html>
  2. <?php
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "";
  6. $dbname = "eerstedatabase";
  7.  
  8. //create connection
  9. $connection = new mysqli($servername, $username, $password, $dbname);
  10.  
  11. if ($_POST) {
  12.  
  13. //check connection
  14. if ($connection->connect_error) {
  15. die("Connection failed: " . $connection->connect_error);
  16. }
  17. //if these posts are empty it updates them to empty in the database aswell
  18. $sql = "UPDATE gebruikers SET Gebruikersnaam='" . $_POST['Gebruikersnaam'] . "',
  19. Wachtwoord='" . $_POST['Wachtwoord'] . "',
  20. Email='" . $_POST['Email'] . "'
  21. WHERE ID='" . $_POST['ID'] . "' ";
  22.  
  23. if ($connection->query($sql) === TRUE) {
  24. echo "Record updated successfully";
  25.  
  26. include 'Opdracht1.php';
  27. } else {
  28. echo "Error updating record: " . $conn->error;
  29. }
  30. }
  31. else
  32. {
  33.  
  34. ?>
  35. <html>
  36. <head>
  37. <meta charset="utf-8">
  38. <title>Naamloos document</title>
  39. </head>
  40.  
  41. <body>
  42. <center>
  43. <table>
  44. <form name="update" action="OpdrachtDW6.php" method="POST">
  45. <tr>
  46. <td>ID</td>
  47. <td><input type="text" name="ID" rquired /></td>
  48. </tr>
  49. <tr>
  50. <td>Gebruikersnaam</td>
  51. <td><input type="text" name="Gebruikersnaam" required /></td>
  52. </tr>
  53. <tr>
  54. <td>Wachtwoord</td>
  55. <td><input type="text" name="Wachtwoord" required /></td>
  56. </tr>
  57. <tr>
  58. <td>Email</td>
  59. <td><input type="text" name="Email" required /></td>
  60. </tr>
  61. <tr>
  62. <td><input type="submit" value="Updaten" /></td>
  63. </tr>
  64. </td>
  65. </form>
  66. </center>
  67. </body>
  68. </html>
  69.  
  70. <?php
  71. }
  72. ?>`
  73.  
  74. $errs = false;
  75.  
  76. if ($_POST['ID'] == "") {
  77. $errs = true;
  78. echo "ID Field Missing";
  79. }
  80. if ($_POST['Gebruikersnaam'] == "") {
  81. $errs = true;
  82. echo "Gebruikersnaam Field Missing";
  83. }
  84.  
  85. /* And so on... */
  86.  
  87. if (!$errs) {
  88. //check connection
  89. if ($connection->connect_error) {
  90. die("Connection failed: " . $connection->connect_error);
  91. }
  92.  
  93. $sql = "UPDATE gebruikers SET Gebruikersnaam='" . $_POST['Gebruikersnaam'] . "',
  94. Wachtwoord='" . $_POST['Wachtwoord'] . "',
  95. Email='" . $_POST['Email'] . "'
  96. WHERE ID='" . $_POST['ID'] . "' ";
  97.  
  98. if ($connection->query($sql) === TRUE) {
  99. echo "Record updated successfully";
  100.  
  101. include 'Opdracht1.php';
  102. } else {
  103. echo "Error updating record: " . $conn->error;
  104. }
  105. }
  106.  
  107. if(empty($_POST['Email'])
  108. // Do something
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement