Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $userid = $_GET['id'];
- $dbhost = "localhost";
- $dbname = "cucurema";
- $username = "root";
- $password = "";
- $connectie = mysqli_connect($dbhost, $username,$password,$dbname);
- if(!$connectie)
- {
- echo "connectie niet geslaagd";
- echo mysqli_error();
- }else{
- echo "connectie geslaagd";
- }
- $query = "SELECT naam, adres, email ";
- $query .="FROM klant ";
- $query .="WHERE id =" . $userid;
- $escapedQuery = mysqli_real_escape_string($connectie, $query);
- $result = mysqli_query($connectie, $escapedQuery);
- if(!$result)
- {
- echo mysqli_error($connectie);
- }
- ?>
- <html>
- <head>
- </head>
- <body>
- <form method="POST">
- <table>
- <?php
- foreach($result as $row)
- { ?>
- <tr><td>Naam <input type="text" name="naam" value= '<?php echo $row['naam'];?>'/></td></tr>
- <tr><td>adres <input type="text" name="adres" value= '<?php echo $row['adres'];?>' /></td></tr>
- <tr><td>email <input type="text" name="email" value= '<?php echo $row['email'];?>' /></td></tr>
- <tr><td><input type="submit" name="btnupdate" value="klik"/></td></tr>
- <?php }?>
- <?php
- if(isset($_POST['btnupdate']))
- {
- $userid = $_GET['id'];
- $firstname = mysqli_real_escape_string($connectie, $_POST['naam']);
- $adres = mysqli_real_escape_string($connectie, $_POST['adres']);
- $email = mysqli_real_escape_string($connectie, $_POST['email']);
- $updatequery='update klant ';
- $updatequery .='SET naam="'.$firstname.'", adres = "'.$adres. '", email="'.$email.'" ';
- $updatequery .='WHERE id='. $userid;
- $result = mysqli_query($connectie, $updatequery);
- if(!$result)
- {
- echo mysqli_error($connectie);
- echo 'ging fout';
- }else{
- echo 'ging goed';
- header('Location: opdracht1.4.php ');
- }
- }
- ?>
- </table>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement