jarv Posted December 15, 2009 Share Posted December 15, 2009 my form updates but my checkboxes or radio buttons don't update?! form <form action="editbike.php" method="post" class="wrap"> <br /><input type="hidden" name="rsUser" value="<? print($_SESSION["RSUSER"]); ?>"/> <br /> <strong>Bike Manufacturer:</strong> <br /> <input type="text" id="f2" class="editbox" name="rsBikeman" value="<? print($record_set['rsBikeman']); ?>"/> <script type="text/javascript"> var f2 = new LiveValidation('f2'); f2.add(Validate.Presence); </script> <br /> <br /> <strong>Bike Model:</strong> <br /> <input type="text" id="f3" class="editbox" name="rsBikemod" value="<? print($record_set['rsBikemod']); ?>"/> <script type="text/javascript"> var f3 = new LiveValidation('f3'); f3.add(Validate.Presence); </script> <br /> <br /> <strong>Bike Year:</strong> <br /> <input type="text" id="f4" class="editbox" name="rsBikeyear" value="<? print($record_set['rsBikeyear']); ?>"/> <script type="text/javascript"> var f4 = new LiveValidation('f4'); f4.add(Validate.Presence); </script> <br /> <br /> <strong>Bike Color:</strong> <br /> <input type="text" id="f5" class="editbox" name="rsBikecolor" value="<? print($record_set['rsBikecolor']); ?>" onFocus="javascript:showMsg(2)"/> <script type="text/javascript"> var f5 = new LiveValidation('f5'); f5.add(Validate.Presence); </script> <input id="msgstatus" type="hidden" value="0" /> <div class="msg" id="msg2" style="display:none;"> You can put more than one colour, please put main color first, eg; white and black (white frame with black logo) <a href="#" onclick="javscript:hideMenu(2)">Close</a></div> <br /> <br /> <strong>Date Taken:</strong> <br /> <input type="text" id="f6" class="editbox" name="rsDatetaken" value="<? print($record_set['rsDatetaken']); ?>"/><br /> YYYY-MM-DD <script type="text/javascript"> var f6 = new LiveValidation('f6'); f6.add(Validate.Presence); </script> <br /> <br /> <strong>Location taken from:</strong> <br /> <input type="text" id="f7" class="editbox" name="rsLocation" value="<? print($record_set['rsLocation']); ?>" onFocus="javascript:showMsg(3)"/> <script type="text/javascript"> var f7 = new LiveValidation('f7'); f7.add(Validate.Presence); </script> <input id="msgstatus" type="hidden" value="0" /> <div class="msg" id="msg3" style="display:none;"> For instance, you may want to put: from outside Tescos in Brighton in East Sussex <a href="#" onclick="javscript:hideMenu(3)">Close</a></div> <br /> <br /> <strong>Location Postcode:</strong> <br /> <input type="text" id="f8" class="editboxshort" name="rsLocpostcode" value="<? print($record_set['rsLocpostcode']); ?>" maxlength="8"/> <script type="text/javascript"> var f8 = new LiveValidation('f8'); f8.add(Validate.Presence); </script> <br /> <br /> <strong>Other Information:</strong> <br /> <input type="text" id="f9" class="editbox" name="rsOtherinfo" value="<? print($record_set['rsOtherinfo']); ?>"/> <br /> <br /> <strong>Was your bike locked?</strong> <br /> Yes<input name="rsLocked" type="radio" value="<? print($record_set['frontSus']); ?>" <?php if ($record_set['rsLocked'] == 'yes') { echo "checked='checked'"; } ?> /> No<input name="rsLocked" type="radio" value="<? print($record_set['rsLocked']); ?>" <?php if ($record_set['rsLocked'] == 'No') { echo "checked='checked'"; } ?>/> <br /> <br /> <strong>If your bike was locked, what type of lock?</strong> <input type="text" id="f10" class="editbox" name="lockType" value="<? print($record_set['lockType']); ?>"/> <br /> <br /> <strong>Extras:</strong> <br /> Front suspension: <input name="frontSus" type="checkbox" value="yes" <?php if ($record_set['frontSus'] == 'yes') { echo "checked='checked'"; } ?> /> <br /> Rear suspension: <input name="rearSus" type="checkbox" value="yes" <?php if ($record_set['rearSus'] == 'yes') { echo "checked='checked'"; } ?> /> <br /> Front light: <input name="frontLight" type="checkbox" value="yes" <?php if ($record_set['frontLight'] == 'yes') { echo "checked='checked'"; } ?> /> <br /> Rear light: <input name="rearLight" type="checkbox" value="yes" <?php if ($record_set['rearLight'] == 'yes') { echo "checked='checked'"; } ?> /> <br /> Bell: <input name="bikeBell" type="checkbox" value="yes" <?php if ($record_set['bikeBell'] == 'yes') { echo "checked='checked'"; } ?> /> <br /> Basket: <input name="bikeBasket" type="checkbox" value="yes" <?php if ($record_set['bikeBasket'] == 'yes') { echo "checked='checked'"; } ?> /> <br /> Bag: <input name="bikeBag" type="checkbox" value="yes" <?php if ($record_set['bikeBag'] == 'yes') { echo "checked='checked'"; } ?> /> <br /> <br /> <br /> <input type="submit" class="button" value="Update" name="Update"/> <br /> </form> edit form page <?php include_once('config.php'); function checkbox_value($name) { return (isset($_POST[$name]) ? 'Yes' : 'No'); } if(isset($_POST['Update'])){ $rsUser = mysql_real_escape_string(stripslashes($_POST['rsUser'])); $rsBikeman = mysql_real_escape_string(stripslashes($_POST['rsBikeman'])); $rsBikemod = mysql_real_escape_string(stripslashes($_POST['rsBikemod'])); $rsBikeyear = mysql_real_escape_string(stripslashes($_POST['rsBikeyear'])); $rsBikecolor = mysql_real_escape_string(stripslashes($_POST['rsBikecolor'])); $rsDatetaken = mysql_real_escape_string(stripslashes($_POST['rsDatetaken'])); $rsLocation = mysql_real_escape_string(stripslashes($_POST['rsLocation'])); $rsLocpostcode = mysql_real_escape_string(stripslashes($_POST['rsLocpostcode'])); $rsOtherinfo = mysql_real_escape_string(stripslashes($_POST['rsOtherinfo'])); $frontSus = mysql_real_escape_string(stripslashes($_POST['frontSus'])); $rearSus = mysql_real_escape_string(stripslashes($_POST['rearSus'])); $rsLocked = mysql_real_escape_string(stripslashes($_POST['rsLocked'])); $lockType = mysql_real_escape_string(stripslashes($_POST['lockType'])); $frontLight = mysql_real_escape_string(stripslashes(checkbox_value($_POST['frontLight']))); $rearLight = mysql_real_escape_string(stripslashes(checkbox_value($_POST['rearLight']))); $bikeBell = mysql_real_escape_string(stripslashes(checkbox_value($_POST['bikeBell']))); $bikeBasket = mysql_real_escape_string(stripslashes(checkbox_value($_POST['bikeBasket']))); $bikeBag = mysql_real_escape_string(stripslashes(checkbox_value($_POST['bikeBag']))); $sql = "UPDATE wmb_members SET rsBikeman='$rsBikeman', rsBikemod='$rsBikemod', rsBikeyear='$rsBikeyear', rsBikecolor='$rsBikecolor', rsDatetaken='$rsDatetaken', rsLocation='$rsLocation', rsLocpostcode='$rsLocpostcode', rsOtherinfo='$rsOtherinfo', frontSus='$frontSus', rearSus='$rearSus', rsLocked='$rsLocked', lockType='$lockType', frontLight='$frontLight', rearLight='$rearLight', bikeBell='$bikeBell', bikeBasket='$bikeBasket', bikeBag='$bikeBag' WHERE rsUser ='".$rsUser."'"; $result = mysql_query($sql) or die('Error: ' . mysql_error() . '<br>SQL: ' . $sql); header("Location: main.php"); } ?> Link to comment https://forums.phpfreaks.com/topic/185244-form-updates-but-checkboxes-or-radio-buttons-dont-update/ Share on other sites More sharing options...
jarv Posted December 15, 2009 Author Share Posted December 15, 2009 please help??! Link to comment https://forums.phpfreaks.com/topic/185244-form-updates-but-checkboxes-or-radio-buttons-dont-update/#findComment-977919 Share on other sites More sharing options...
mrMarcus Posted December 15, 2009 Share Posted December 15, 2009 echo out $sql and see if the query is what you want it to be. Link to comment https://forums.phpfreaks.com/topic/185244-form-updates-but-checkboxes-or-radio-buttons-dont-update/#findComment-977939 Share on other sites More sharing options...
jarv Posted December 15, 2009 Author Share Posted December 15, 2009 ok so I echoed out the SQL like so: $sql = "UPDATE wmb_members SET rsBikeman='$rsBikeman', rsBikemod='$rsBikemod', rsBikeyear='$rsBikeyear', rsBikecolor='$rsBikecolor', rsDatetaken='$rsDatetaken', rsLocation='$rsLocation', rsLocpostcode='$rsLocpostcode', rsOtherinfo='$rsOtherinfo', frontSus='$frontSus', rearSus='$rearSus', rsLocked='$rsLocked', lockType='$lockType', frontLight='$frontLight', rearLight='$rearLight', bikeBell='$bikeBell', bikeBasket='$bikeBasket', bikeBag='$bikeBag' WHERE rsUser ='".$rsUser."'"; echo $sql; end; //$result = mysql_query($sql) or die('Error: ' . mysql_error() . '<br>SQL: ' . $sql); //header("Location: main.php"); and this is what i got back: Notice: Undefined index: rearSus in D:\wheresmybike.co.uk\wwwroot\editbike.php on line 17 Notice: Undefined index: bikeBasket in D:\wheresmybike.co.uk\wwwroot\editbike.php on line 23 Notice: Undefined index: bikeBag in D:\wheresmybike.co.uk\wwwroot\editbike.php on line 24 UPDATE wmb_members SET rsBikeman='Focus', rsBikemod='Raven', rsBikeyear='2008', rsBikecolor='Black and whIte', rsDatetaken='2009-11-11', rsLocation='Ropetackle, shoreham by sea', rsLocpostcode='bn45', rsOtherinfo='none', frontSus='yes', rearSus='', rsLocked='yes', lockType='kryptonite', frontLight='No', rearLight='No', bikeBell='No', bikeBasket='No', bikeBag='No' WHERE rsUser ='john' Notice: Use of undefined constant end - assumed 'end' in D:\wheresmybike.co.uk\wwwroot\editbike.php on line 29 I checked for frontLight and rearLight and bikeBell and all came back 'No' Link to comment https://forums.phpfreaks.com/topic/185244-form-updates-but-checkboxes-or-radio-buttons-dont-update/#findComment-977953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.