gegevens worden NIET bewerkt :S
Appie_Dijk - 02/11/2005 14:49
Lid
Hallo iedereen,
op één of andere manier worden de gegevens in de database niet bewerkt...
<?php
include("config.php");
$id = $_GET['id'];
$select = mysql_query(" SELECT * FROM maaidorser WHERE id='". $id ."'");
$obj = mysql_fetch_object($select);
if(isset($_POST['submit'])) {
$merk = $_POST['merk'];
$type = $_POST['type'];
$urenstand = $_POST['urenstand'];
$algemenestaat = $_POST['algemenestaat'];
$btw = $_POST['btw'];
$prijs = $_POST['prijs'];
$extrainfo1 = $_POST['extrainfo1'];
$extrainfo2 = $_POST['extrainfo2'];
$extrainfo3 = $_POST['extrainfo3'];
$extrainfo4 = $_POST['extrainfo4'];
$extrainfo5 = $_POST['extrainfo5'];
$omschrijving = $_POST['omschrijving'];
mysql_query(" UPDATE maaidorser SET merk='". $merk ."', '". $type ."', '". $bouwjaar ."', '". $urenstand ."', '". $algemenestaat ."', '". $btw ."', '". $prijs ."', '". $extrainfo1 ."', '". $extrainfo2 ."', '". $extrainfo3 ."', '". $extrainfo4 ."', '". $extrainfo5 ."', '". $omschrijving ."' WHERE id='". $id ."'");
echo "De gegevens zijn bewerkt.<br>";
echo "klik <a href='admin.php'>hier</a> om terug te gaan.<br>";
} else {
?>
<form action="" method="post">
<table width="600">
<tr><td width="600" bgcolor="#BBE100" colspan="5"><b>Merk:
<input name="merk" type="text" value="<?php echo $obj->merk; ?>" maxlength="250" size="75"></b></td></tr>
<tr><td width="600" bgcolor="#BBE100" colspan="5"><b>Type:
<input name="type" type="text" value="<?php echo $obj->type; ?>" maxlength="250" size="76"></b></td></tr>
<tr><td width="600" colspan="5" bgcolor="#BBE100"><b>Omschrijving:
<input name="omschrijving" type="text" value="<?php echo $obj->omschrijving; ?>" maxlength="250" size="67"></b></td></tr>
<tr><td width="225" rowspan="13" valign="top"></td>
<td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>Bouwjaar</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="bouwjaar" type="text" value="<?php echo $obj->bouwjaar; ?>" maxlength="4" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>Urenstand</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="urenstand" type="text" value="<?php echo $obj->urenstand; ?>" maxlength="10" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>Algemene staat</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="algemenestaat" type="text" value="<?php echo $obj->algemenestaat; ?>" maxlength="50" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>BTW / Marge</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="btw" type="text" value="<?php echo $obj->btw; ?>" maxlength="10" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>Prijs excl.</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="prijs" type="text" value="<?php echo $obj->prijs; ?>" maxlength="10" size="26"></td></tr>
<tr>
<td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>Extra informatie</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="extrainfo1" type="text" value="<?php echo $obj->extrainfo1; ?>" maxlength="250" size="26"></td>
</tr>
<tr><td width="10"> </td>
<td width="155"> </td>
<td width="10" align="center"> </td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="extrainfo2" type="text" value="<?php echo $obj->extrainfo2; ?>" maxlength="250" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155"> </td>
<td width="10" align="center"> </td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="extrainfo3" type="text" value="<?php echo $obj->extrainfo3; ?>" maxlength="250" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155"> </td>
<td width="10" align="center"> </td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="extrainfo4" type="text" value="<?php echo $obj->extrainfo4; ?>" maxlength="250" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155"> </td>
<td width="10" align="center"> </td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="extrainfo5" type="text" value="<?php echo $obj->extrainfo5; ?>" maxlength="250" size="26"></td></tr>
<tr><td colspan="4"> </td></tr>
<tr><td colspan="4"><input type="submit" value="Gegevens bewerken" name="submit"><input type="reset" value="Annuleren"></td></tr>
</table>
</form>
<?
echo "<a href='admin.php'>Ga terug</a><br>";
}
?>
<?php
include ( "config.php" ) ;
$id = $_GET [ 'id' ] ;
$select = mysql_query ( " SELECT * FROM maaidorser WHERE id='" . $id . "'" ) ;
if ( isset ( $_POST [ 'submit' ] ) ) { $merk = $_POST [ 'merk' ] ;
$type = $_POST [ 'type' ] ;
$urenstand = $_POST [ 'urenstand' ] ;
$algemenestaat = $_POST [ 'algemenestaat' ] ;
$btw = $_POST [ 'btw' ] ;
$prijs = $_POST [ 'prijs' ] ;
$extrainfo1 = $_POST [ 'extrainfo1' ] ;
$extrainfo2 = $_POST [ 'extrainfo2' ] ;
$extrainfo3 = $_POST [ 'extrainfo3' ] ;
$extrainfo4 = $_POST [ 'extrainfo4' ] ;
$extrainfo5 = $_POST [ 'extrainfo5' ] ;
$omschrijving = $_POST [ 'omschrijving' ] ;
mysql_query ( " UPDATE maaidorser SET merk='" . $merk . "', '" . $type . "', '" . $bouwjaar . "', '" . $urenstand . "', '" . $algemenestaat . "', '" . $btw . "', '" . $prijs . "', '" . $extrainfo1 . "', '" . $extrainfo2 . "', '" . $extrainfo3 . "', '" . $extrainfo4 . "', '" . $extrainfo5 . "', '" . $omschrijving . "' WHERE id='" . $id . "'" ) ;
echo "De gegevens zijn bewerkt.<br>" ; echo "klik <a href='admin.php'>hier</a> om terug te gaan.<br>" ; } else {
?>
<form action="" method="post">
<table width="600">
<tr><td width="600" bgcolor="#BBE100" colspan="5"><b>Merk:
<input name="merk" type="text" value="
<?php echo $obj -> merk ; ?> " maxlength="250" size="75"></b></td></tr>
<tr><td width="600" bgcolor="#BBE100" colspan="5"><b>Type:
<input name="type" type="text" value="
<?php echo $obj -> type ; ?> " maxlength="250" size="76"></b></td></tr>
<tr><td width="600" colspan="5" bgcolor="#BBE100"><b>Omschrijving:
<input name="omschrijving" type="text" value="
<?php echo $obj -> omschrijving ; ?> " maxlength="250" size="67"></b></td></tr>
<tr><td width="225" rowspan="13" valign="top"></td>
<td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>Bouwjaar</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="bouwjaar" type="text" value="
<?php echo $obj -> bouwjaar ; ?> " maxlength="4" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>Urenstand</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="urenstand" type="text" value="
<?php echo $obj -> urenstand ; ?> " maxlength="10" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>Algemene staat</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="algemenestaat" type="text" value="
<?php echo $obj -> algemenestaat ; ?> " maxlength="50" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>BTW / Marge</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="btw" type="text" value="
<?php echo $obj -> btw ; ?> " maxlength="10" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>Prijs excl.</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="prijs" type="text" value="
<?php echo $obj -> prijs ; ?> " maxlength="10" size="26"></td></tr>
<tr>
<td width="10"> </td>
<td width="155" bgcolor="#BBE100" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<b>Extra informatie</b></td>
<td width="10" align="center"><b>:</b></td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="extrainfo1" type="text" value="
<?php echo $obj -> extrainfo1 ; ?> " maxlength="250" size="26"></td>
</tr>
<tr><td width="10"> </td>
<td width="155"> </td>
<td width="10" align="center"> </td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="extrainfo2" type="text" value="
<?php echo $obj -> extrainfo2 ; ?> " maxlength="250" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155"> </td>
<td width="10" align="center"> </td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="extrainfo3" type="text" value="
<?php echo $obj -> extrainfo3 ; ?> " maxlength="250" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155"> </td>
<td width="10" align="center"> </td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="extrainfo4" type="text" value="
<?php echo $obj -> extrainfo4 ; ?> " maxlength="250" size="26"></td></tr>
<tr><td width="10"> </td>
<td width="155"> </td>
<td width="10" align="center"> </td>
<td width="200" style="border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom: 1px solid #BBE100">
<input name="extrainfo5" type="text" value="
<?php echo $obj -> extrainfo5 ; ?> " maxlength="250" size="26"></td></tr>
<tr><td colspan="4"> </td></tr>
<tr><td colspan="4"><input type="submit" value="Gegevens bewerken" name="submit"><input type="reset" value="Annuleren"></td></tr>
</table>
</form>
<?
echo "<a href='admin.php'>Ga terug</a><br>" ; }
?>
zal wel iets kleins zijn, maar ik zie het niet...
4 antwoorden
Gesponsorde links
Gerard - 02/11/2005 15:10
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
<form action="" method="post">
< form action= "" method= "post" >
veranderen in
<form action="?id=<?= $_GET['id']; ?>" method="post">
<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.
Appie_Dijk - 02/11/2005 15:14 (laatste wijziging 02/11/2005 15:57)
Lid
sorry gebeurt niets als ik:
<form action="" method="post">
verander in:
<form action="?id=<?= $_GET['id']; ?>" method="post">
Gerard - 02/11/2005 15:40 (laatste wijziging 02/11/2005 15:41)
Ouwe rakker
komt het id wel in de url balk erbij te staan?
anders moet je het eens veranderen in
<form action="admin.php?id=<?= $id; ?>" method="post">
<form action="admin.php?id=<?= $id ; ?> " method="post">
Appie_Dijk - 02/11/2005 15:58
Lid
heb t al gevonden...:
mysql_query(" UPDATE maaidorser SET merk='". $merk ."', '". $type ."', '". $bouwjaar ."', '". $urenstand ."', '". $algemenestaat ."', '". $btw ."', '". $prijs ."', '". $extrainfo1 ."', '". $extrainfo2 ."', '". $extrainfo3 ."', '". $extrainfo4 ."', '". $extrainfo5 ."', '". $omschrijving ."' WHERE id='". $id ."'");
mysql_query ( " UPDATE maaidorser SET merk='" . $merk . "', '" . $type . "', '" . $bouwjaar . "', '" . $urenstand . "', '" . $algemenestaat . "', '" . $btw . "', '" . $prijs . "', '" . $extrainfo1 . "', '" . $extrainfo2 . "', '" . $extrainfo3 . "', '" . $extrainfo4 . "', '" . $extrainfo5 . "', '" . $omschrijving . "' WHERE id='" . $id . "'" ) ;
moet zijn:
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."'");
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 .