login  Naam:   Wachtwoord: 
Registreer je!
 Forum

gegevens worden NIET bewerkt :S

Offline Appie_Dijk - 02/11/2005 14:49
Avatar van Appie_DijkLid Hallo iedereen,

op één of andere manier worden de gegevens in de database niet bewerkt...

  1. <?php
  2. include("config.php");
  3. $id = $_GET['id'];
  4. $select = mysql_query(" SELECT * FROM maaidorser WHERE id='". $id ."'");
  5. $obj = mysql_fetch_object($select);
  6.  
  7. if(isset($_POST['submit'])) {
  8. $merk = $_POST['merk'];
  9. $type = $_POST['type'];
  10. $urenstand = $_POST['urenstand'];
  11. $algemenestaat = $_POST['algemenestaat'];
  12. $btw = $_POST['btw'];
  13. $prijs = $_POST['prijs'];
  14. $extrainfo1 = $_POST['extrainfo1'];
  15. $extrainfo2 = $_POST['extrainfo2'];
  16. $extrainfo3 = $_POST['extrainfo3'];
  17. $extrainfo4 = $_POST['extrainfo4'];
  18. $extrainfo5 = $_POST['extrainfo5'];
  19. $omschrijving = $_POST['omschrijving'];
  20.  
  21. mysql_query(" UPDATE maaidorser SET merk='". $merk ."', '". $type ."', '". $bouwjaar ."', '". $urenstand ."', '". $algemenestaat ."', '". $btw ."', '". $prijs ."', '". $extrainfo1 ."', '". $extrainfo2 ."', '". $extrainfo3 ."', '". $extrainfo4 ."', '". $extrainfo5 ."', '". $omschrijving ."' WHERE id='". $id ."'");
  22.  
  23. echo "De gegevens zijn bewerkt.<br>";
  24. echo "klik <a href='admin.php'>hier</a> om terug te gaan.<br>";
  25. } else {
  26. ?>
  27. <form action="" method="post">
  28. <table width="600">
  29. <tr><td width="600" bgcolor="#BBE100" colspan="5"><b>Merk:
  30. <input name="merk" type="text" value="<?php echo $obj->merk; ?>" maxlength="250" size="75"></b></td></tr>
  31. <tr><td width="600" bgcolor="#BBE100" colspan="5"><b>Type:
  32. <input name="type" type="text" value="<?php echo $obj->type; ?>" maxlength="250" size="76"></b></td></tr>
  33. <tr><td width="600" colspan="5" bgcolor="#BBE100"><b>Omschrijving:
  34. <input name="omschrijving" type="text" value="<?php echo $obj->omschrijving; ?>" maxlength="250" size="67"></b></td></tr>
  35. <tr><td width="225" rowspan="13" valign="top"></td>
  36. <td width="10">&nbsp;</td>
  37. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  38. <b>Bouwjaar</b></td>
  39. <td width="10" align="center"><b>:</b></td>
  40. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  41. <input name="bouwjaar" type="text" value="<?php echo $obj->bouwjaar; ?>" maxlength="4" size="26"></td></tr>
  42. <tr><td width="10">&nbsp;</td>
  43. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  44. <b>Urenstand</b></td>
  45. <td width="10" align="center"><b>:</b></td>
  46. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  47. <input name="urenstand" type="text" value="<?php echo $obj->urenstand; ?>" maxlength="10" size="26"></td></tr>
  48. <tr><td width="10">&nbsp;</td>
  49. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  50. <b>Algemene staat</b></td>
  51. <td width="10" align="center"><b>:</b></td>
  52. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  53. <input name="algemenestaat" type="text" value="<?php echo $obj->algemenestaat; ?>" maxlength="50" size="26"></td></tr>
  54. <tr><td width="10">&nbsp;</td>
  55. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  56. <b>BTW / Marge</b></td>
  57. <td width="10" align="center"><b>:</b></td>
  58. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  59. <input name="btw" type="text" value="<?php echo $obj->btw; ?>" maxlength="10" size="26"></td></tr>
  60. <tr><td width="10">&nbsp;</td>
  61. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  62. <b>Prijs excl.</b></td>
  63. <td width="10" align="center"><b>:</b></td>
  64. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  65. <input name="prijs" type="text" value="<?php echo $obj->prijs; ?>" maxlength="10" size="26"></td></tr>
  66.  
  67. <tr>
  68. <td width="10">&nbsp;</td>
  69. <td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  70. <b>Extra informatie</b></td>
  71. <td width="10" align="center"><b>:</b></td>
  72. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  73. <input name="extrainfo1" type="text" value="<?php echo $obj->extrainfo1; ?>" maxlength="250" size="26"></td>
  74. </tr>
  75.  
  76. <tr><td width="10">&nbsp;</td>
  77. <td width="155">&nbsp;</td>
  78. <td width="10" align="center">&nbsp;</td>
  79. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  80. <input name="extrainfo2" type="text" value="<?php echo $obj->extrainfo2; ?>" maxlength="250" size="26"></td></tr>
  81.  
  82. <tr><td width="10">&nbsp;</td>
  83. <td width="155">&nbsp;</td>
  84. <td width="10" align="center">&nbsp;</td>
  85. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  86. <input name="extrainfo3" type="text" value="<?php echo $obj->extrainfo3; ?>" maxlength="250" size="26"></td></tr>
  87.  
  88. <tr><td width="10">&nbsp;</td>
  89. <td width="155">&nbsp;</td>
  90. <td width="10" align="center">&nbsp;</td>
  91. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  92. <input name="extrainfo4" type="text" value="<?php echo $obj->extrainfo4; ?>" maxlength="250" size="26"></td></tr>
  93.  
  94. <tr><td width="10">&nbsp;</td>
  95. <td width="155">&nbsp;</td>
  96. <td width="10" align="center">&nbsp;</td>
  97. <td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
  98. <input name="extrainfo5" type="text" value="<?php echo $obj->extrainfo5; ?>" maxlength="250" size="26"></td></tr>
  99. <tr><td colspan="4">&nbsp;</td></tr>
  100. <tr><td colspan="4"><input type="submit" value="Gegevens bewerken" name="submit"><input type="reset" value="Annuleren"></td></tr>
  101. </table>
  102. </form>
  103. <?
  104. echo "<a href='admin.php'>Ga terug</a><br>";
  105. }
  106. ?>


zal wel iets kleins zijn, maar ik zie het niet...

4 antwoorden

Gesponsorde links
Offline Gerard - 02/11/2005 15:10
Avatar van Gerard Ouwe rakker Dit is een klein potje logisch denken. Je komt binnen op jouw pagina en direct zet hij de ?id=x om in de var $id. Dit werkt natuurlijk leuk bij het gegevens opvragen.

Op het moment dat je echter je formulier submit om zo de gegevens te verwerken moet je wel zorgen dat je op 1 of andere manier dat id meegeeft via het formulier omdat het niet meer in de url staat als je op 'submit' hebt gedrukt.

Wat je altijd kan doen is dit

  1. <form action="" method="post">


veranderen in

  1. <form action="?id=<?= $_GET['id']; ?>" method="post">


Op dat moment stuurt hij het ID wederom door en zal de query wel weten welke rij hij moet updaten.
Offline Appie_Dijk - 02/11/2005 15:14 (laatste wijziging 02/11/2005 15:57)
Avatar van Appie_Dijk Lid sorry gebeurt niets als ik:

<form action="" method="post">
verander in:
<form action="?id=<?= $_GET['id']; ?>" method="post">
Offline Gerard - 02/11/2005 15:40 (laatste wijziging 02/11/2005 15:41)
Avatar van Gerard Ouwe rakker komt het id wel in de url balk erbij te staan?

anders moet je het eens veranderen in

  1. <form action="admin.php?id=<?= $id; ?>" method="post">
Offline Appie_Dijk - 02/11/2005 15:58
Avatar van Appie_Dijk Lid heb t al gevonden...:

  1. mysql_query(" UPDATE maaidorser SET merk='". $merk ."', '". $type ."', '". $bouwjaar ."', '". $urenstand ."', '". $algemenestaat ."', '". $btw ."', '". $prijs ."', '". $extrainfo1 ."', '". $extrainfo2 ."', '". $extrainfo3 ."', '". $extrainfo4 ."', '". $extrainfo5 ."', '". $omschrijving ."' WHERE id='". $id ."'");


moet zijn:

  1. mysql_query("UPDATE maaidorser SET merk='".$merk."', type='".$type."', bouwjaar='".$bouwjaar."', urenstand='".$urenstand."', algemenestaat='".$algemenestaat."', btw='".$btw."', prijs='".$prijs."', extrainfo1='".$extrainfo1."', extrainfo2='".$extrainfo2."', extrainfo3='".$extrainfo3."', extrainfo4='".$extrainfo4."', extrainfo5='".$extrainfo5."', omschrijving='".$omschrijving."' WHERE id='".$id."'");
Gesponsorde links
Dit onderwerp is gesloten.
Actieve forumberichten
© 2002-2025 Sitemasters.be - Regels - Laadtijd: 0.25s