Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `<!doctype html>
- <?php
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "eerstedatabase";
- //create connection
- $connection = new mysqli($servername, $username, $password, $dbname);
- if ($_POST) {
- //check connection
- if ($connection->connect_error) {
- die("Connection failed: " . $connection->connect_error);
- }
- //if these posts are empty it updates them to empty in the database aswell
- $sql = "UPDATE gebruikers SET Gebruikersnaam='" . $_POST['Gebruikersnaam'] . "',
- Wachtwoord='" . $_POST['Wachtwoord'] . "',
- Email='" . $_POST['Email'] . "'
- WHERE ID='" . $_POST['ID'] . "' ";
- if ($connection->query($sql) === TRUE) {
- echo "Record updated successfully";
- include 'Opdracht1.php';
- } else {
- echo "Error updating record: " . $conn->error;
- }
- }
- else
- {
- ?>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Naamloos document</title>
- </head>
- <body>
- <center>
- <table>
- <form name="update" action="OpdrachtDW6.php" method="POST">
- <tr>
- <td>ID</td>
- <td><input type="text" name="ID" rquired /></td>
- </tr>
- <tr>
- <td>Gebruikersnaam</td>
- <td><input type="text" name="Gebruikersnaam" required /></td>
- </tr>
- <tr>
- <td>Wachtwoord</td>
- <td><input type="text" name="Wachtwoord" required /></td>
- </tr>
- <tr>
- <td>Email</td>
- <td><input type="text" name="Email" required /></td>
- </tr>
- <tr>
- <td><input type="submit" value="Updaten" /></td>
- </tr>
- </td>
- </form>
- </center>
- </body>
- </html>
- <?php
- }
- ?>`
- $errs = false;
- if ($_POST['ID'] == "") {
- $errs = true;
- echo "ID Field Missing";
- }
- if ($_POST['Gebruikersnaam'] == "") {
- $errs = true;
- echo "Gebruikersnaam Field Missing";
- }
- /* And so on... */
- if (!$errs) {
- //check connection
- if ($connection->connect_error) {
- die("Connection failed: " . $connection->connect_error);
- }
- $sql = "UPDATE gebruikers SET Gebruikersnaam='" . $_POST['Gebruikersnaam'] . "',
- Wachtwoord='" . $_POST['Wachtwoord'] . "',
- Email='" . $_POST['Email'] . "'
- WHERE ID='" . $_POST['ID'] . "' ";
- if ($connection->query($sql) === TRUE) {
- echo "Record updated successfully";
- include 'Opdracht1.php';
- } else {
- echo "Error updating record: " . $conn->error;
- }
- }
- if(empty($_POST['Email'])
- // Do something
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement