Advertisement
Guest User

update code

a guest
Jun 4th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. <center>
  2. <?php
  3. function test_input($temp){
  4. $temp = trim($temp);
  5. $temp = stripslashes($temp);
  6. $temp = htmlspecialchars($temp);
  7. return $temp;
  8. }
  9. $servername ="localhost";
  10. $username = "root";
  11. $password = "usbw";
  12. $dbname = "GIP";
  13.  
  14. $connect1 = new mysqli($servername, $username, $password, $dbname);
  15.  
  16. if($connect1->connect_error)
  17. {
  18. die("Connection failed: " . $connnect1->connect_error);
  19. }
  20. if(isset($_POST["btnUpdateStick"])) // als op de knop verander gedrukt wordt (van stick)
  21. {
  22. //vraag het artikeID op dat je meegeeft in de url
  23. //maak een nieuwe variabele aan waar je de gestripte waarde uit het gelijknamige veld insteekt.
  24. $artID=$_GET["ID"];
  25. $foto2=test_input($_POST["txtFoto"]);
  26. $naam2=test_input($_POST["txtNaam"]);
  27. $merk2=test_input($_POST["txtMerk"]);
  28. $maat2=test_input($_POST["txtMaat"]);
  29. $materiaal2=test_input($_POST["txtMateriaal"]);
  30. $prijs2=test_input($_POST["txtPrijs"]);
  31. $omschrijving1=htmlentities($_POST["txtOmschrijving1"]);
  32. $omschrijving2=htmlentities($_POST["txtOmschrijving2"]);
  33. $omschrijving3=htmlentities($_POST["txtOmschrijving3"]);
  34. //SQL-query UPDATE: overschrijf in de databank de oude waarden met de nieuwe
  35. $sql = "UPDATE sticks SET Stick_Foto='$foto2', Stick_Naam='$naam2', Stick_Merk='$merk2', Stick_Maat='$maat2', Stick_Materiaal='$materiaal2', Stick_Prijs='$prijs2', Stick_Omschrijving='$omschrijving1', Stick_Omschrijving_EN = '$omschrijving2', Stick_Omschrijving_FR = '$omschrijving3' WHERE Stick_ID='$artID'";
  36. $qresult = $connect1->query($sql);
  37. echo $sql;
  38. header("Location: http://localhost:8080/GIP/webpaginas/stick_admin.php");
  39. }
  40. if(isset($_POST["btnUpdateShirt"])) // als op de knop verander gedrukt wordt (van stick)
  41. {
  42. //vraag het artikeID op dat je meegeeft in de url
  43. //maak een nieuwe variabele aan waar je de gestripte waarde uit het gelijknamige veld insteekt.
  44. $artID=$_GET["ID"];
  45. $foto2=test_input($_POST["txtFoto"]);
  46. $naam2=test_input($_POST["txtNaam"]);
  47. $merk2=test_input($_POST["txtMerk"]);
  48. $maat2=test_input($_POST["txtMaat"]);
  49. $materiaal2=test_input($_POST["txtMateriaal"]);
  50. $prijs2=test_input($_POST["txtPrijs"]);
  51. $omschrijving1=htmlentities($_POST["txtOmschrijving1"]);
  52. $omschrijving2=htmlentities($_POST["txtOmschrijving2"]);
  53. $omschrijving3=htmlentities($_POST["txtOmschrijving3"]);
  54. //SQL-query UPDATE: overschrijf in de databank de oude waarden met de nieuwe
  55. $sql = "UPDATE shirts SET Shirt_Foto='$foto2', Shirt_Naam='$naam2', Shirt_Merk='$merk2', Shirt_Maat='$maat2', Shirt_Stof='$materiaal2', Shirt_Prijs='$prijs2', Shirt_Omschrijving='$omschrijving1', Shirt_Omschrijving_EN='$omschrijving2', Shirt_Omschrijving_FR='$omschrijving3' WHERE Shirt_ID='$artID'";
  56. $qresult = $connect1->query($sql);
  57. echo $sql;
  58. header("Location: http://localhost:8080/GIP/webpaginas/shirt_admin.php");
  59. }
  60. else{
  61. header("Location: http://localhost:8080/GIP/webpaginas/home_admin.php");
  62. }
  63.  
  64. $connect1->close();
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement