jarv Posted December 16, 2009 Share Posted December 16, 2009 it doesn't come back with any errors just checkboxes and radiobuttons don't work?! <?php include_once("config.php"); include_once("functions.php"); // Check user logged in already: checkLoggedIn("yes"); doCSS(); 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 = checkbox_value('frontLight'); $rearLight = checkbox_value('rearLight'); $bikeBell = checkbox_value('bikeBell'); $bikeBasket = checkbox_value('bikeBasket'); $bikeBag = checkbox_value('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"); } $result = mysql_query("SELECT * FROM wmb_members WHERE RSUSER = '".$RSUSER."'"); if (!$result) { die('Invalid query: ' . mysql_error()); } else if (mysql_num_rows($result) == 1) { $record_set = mysql_fetch_assoc($result); } else { // this means it has more or less than 1 row die('UNEXPECTED ERROR!'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" /> <title>Mountain bike stolen from Ropetackle, Adur business centre, Shoreham-by-sea, West Sussex</title> <meta name="description" content="Bike thief, chav in white hoodie steals bike from car park in Shoreham" /> <meta name="keywords" content="steal, thief, stole, mountain bike, bicycle, work, shoreham, sussex, ropetackle" /> <meta name="Content-Language" content="en-gb" /> <meta name="robots" content="FOLLOW,INDEX" /> <meta name="revisit-after" content="2 days" /> <meta name="copyright" content="www.wheresmybike.co.uk" /> <meta name="author" content="www.mutecms.com - Professional web site design in the south uk, worthing, brighton" /> <meta name="distribution" content="Global" /> <meta name="resource-type" content="document" /> <script src="js/livevalidation_standalone.compressed.js" type="text/javascript"></script> <script src="scriptaculous/lib/prototype.js" type="text/javascript"></script> <script src="scriptaculous/src/scriptaculous.js" type="text/javascript"></script> <script language="javascript"> function showMsg(idElement){ idEl=idElement; msgStatus = document.getElementById('msgstatus'); if(msgStatus.value==0){ msgStatus.value=1; Effect.toggle('msg'+idEl,'appear'); return false; } } function hideMenu(idElement){ idEl=idElement; msgStatus = document.getElementById('msgstatus'); if(msgStatus.value==1){ msgStatus.value=0; Effect.toggle('msg'+idEl,'appear'); return false; } } </script> <script type="text/javascript" src="js/jva.js"></script> <link rel="stylesheet" type="text/css" href="css/reset-style.css" /> <link rel="stylesheet" type="text/css" href="css/sitestyle.css" /> <!-- CSS --> <link rel="stylesheet" type="text/css" href="css/default.css" /> <link rel="stylesheet" type="text/css" href="css/lightwindow.css" /> <!-- JavaScript --> <script type="text/javascript" src="javascript/prototype.js"></script> <script type="text/javascript" src="javascript/effects.js"></script> <script type="text/javascript" src="javascript/lightwindow.js"></script> </head> <body> <div id="doc"> <div id="hd"> <h1>Where's my bike?</h1> <div class="manbike"></div> <div class="cctv"></div> <ul> <li><a href="logout.php">logout</a></li> </ul> </div> <div id="bd"> <div class="yui-g"> <div class="topcontent"> </div> <div id="leftcolumn" class="yui-u first"> <h2>Welcome <? print($_SESSION["RSUSER"]); ?></h2> <img src="images/bike.jpg" alt="stolen Focus mountain bike"/><br /><br /> </div> <div class="yui-u" id="rightcol"> <h2>Please sign up if you have recently had your bike stolen!</h2> <h3>You will be added to our stolen bike victims database</h3> <a href="form.html" params="lightwindow_width=375,lightwindow_height=400" class="lightwindow"></a> <form action="main.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> </div> </div> <div id="ft">Site created by: <a href="http://www.jbiddulph.com">jbiddulph.com</a></div> </div> </div> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-2434589-16"); pageTracker._trackPageview(); } catch(err) {}</script> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/185339-update-page-not-updating-checkboxes-or-radio-buttons/ Share on other sites More sharing options...
jarv Posted December 16, 2009 Author Share Posted December 16, 2009 well, I have managed to get around the check boxes, my problem was the UPPERCASE 'Y' for Yes my problem now is the radio buttons! Quote Link to comment https://forums.phpfreaks.com/topic/185339-update-page-not-updating-checkboxes-or-radio-buttons/#findComment-978408 Share on other sites More sharing options...
PFMaBiSmAd Posted December 16, 2009 Share Posted December 16, 2009 For debugging purposes, add the following at the start of your form processing code in order to see exactly what you are receiving from the form - echo "<pre>"; echo "POST:"; print_r($_POST); echo "</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/185339-update-page-not-updating-checkboxes-or-radio-buttons/#findComment-978518 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.