Xtremer360 Posted February 10, 2011 Share Posted February 10, 2011 Okay after correcting the issues with the jQuery side of things I'm having a small error with the php processing side. I'm getting a response back in firebug that there is an undefined index "name" and undefined index "value". Now I'm not sure on a fix but I know I'll have to do some sort of foreach I think because on the jquery dataString is a each so there's going to be more than name and value coming in at one time. <?php error_reporting(E_ALL); // Include the database page include ('../inc/dbconfig.php'); $styleID = $_GET['id']; $query = "SELECT fields.ID, fields.fullName, fields.enabled FROM fields INNER JOIN styles ON styles.ID = fields.styleID WHERE styles.ID = '" . $styleID . "'"; $result = mysqli_query ( $dbc, $query ); // Run The Query ?> <script> $(document).ready(function() { $('div.message-error').hide(); $('div.message-success').hide(); $("input.submit").click(function() { $('div.message-error').hide(); var dataString = '&submitBioFields=True'; $('#bioConfigForm .field').each(function() { dataString += '&'+$(this).find('input:first').attr('name')+'='; dataString += ($(this).find('input[value|=0]').is(':checked')) ? '0' : '1'; }); alert(dataString); $.ajax({ type: "POST", url: "processes/bioconfig.php", data: dataString, success: function() { $('div.message-error').hide(); $("div.message-success").html("<h6>Operation successful</h6><p>Bio fields saved successfully.</p>"); $("div.message-success").show().delay(10000).hide("slow", function() { $('#content').load('mods/bioconfiguration.php'); }); } }); return false; }); }); </script> <!-- Title --> <div id="title" class="b2"> <h2>Bio Configuration</h2> <!-- TitleActions --> <div id="titleActions"> <!-- ListSearch --> <div class="listSearch actionBlock"> <div class="search"> <label for="search">Recherche</label> <input type="text" name="search" id="search" class="text" /> </div> <div class="submit"> <button type="submit" id="search-button" class="button"><strong><img src="img/icons/search_48.png" alt="comments" class="icon "/></strong></button> </div> </div> <!-- /ListSearch --> </div> <!-- /TitleActions --> </div> <!-- Title --> <!-- Inner Content --> <div id="innerContent"> <!-- Form --> <form action="#" id="bioConfigForm" > <fieldset> <legend>Bio Config</legend> <?php while ( $row = mysqli_fetch_array ( $result, MYSQL_ASSOC ) ) { ?> <div class="field"> <label for="<?php '' . $row['ID'] . '' ?>"><?php echo '' . $row['fullName'] . ''?></label> <input type="radio" value="0" name="<?php echo $row['ID']; ?>" class="status" <?php if($row['enabled'] == 0) echo ' checked="checked"'; ?> />Enabled <input type="radio" value="1" name="<?php echo $row['ID']; ?>" class="status" <?php if($row['enabled'] == 1) echo ' checked="checked"'; ?> />Disabled </div> <?php } ?> <input type="submit" class="submit" name="submitBioFields" id="SubmitBioFields" title="Submit Bio Fields" value="Submit Bio Fields"/> </fieldset> </form> <!-- /Form --> <!-- Messages --> <div class="message message-error"> <h6>Required field missing</h6> <p>Please fill in all required fields. </p> </div> <div class="message message-success"> <h6>Operation succesful</h6> <p>Bio configuraton was eddited to the database.</p> </div> <!-- /Messages --> <?php error_reporting(E_ALL); // Include the database page require ('../inc/dbconfig.php'); if (isset($_POST['submitBioFields'])) { $fieldID = (int)$_POST['name']; $value = (int)$_POST['value']; $query = "UPDATE `fields` SET `enabled` = '".$value."' WHERE `ID` = '".$fieldID."'"; mysqli_query($dbc,$query); $result = "good"; } //Output the result echo $result; ?> Quote Link to comment https://forums.phpfreaks.com/topic/227279-processing-page-values/ Share on other sites More sharing options...
BlueSkyIS Posted February 10, 2011 Share Posted February 10, 2011 without seeing the entire error, i assume it's on these lines: $fieldID = (int)$_POST['name']; $value = (int)$_POST['value']; and means that neither $_POST['name'] nor $_POST['value'] are defined. Quote Link to comment https://forums.phpfreaks.com/topic/227279-processing-page-values/#findComment-1172367 Share on other sites More sharing options...
Xtremer360 Posted February 11, 2011 Author Share Posted February 11, 2011 Any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/227279-processing-page-values/#findComment-1172557 Share on other sites More sharing options...
Jessica Posted February 11, 2011 Share Posted February 11, 2011 Any other ideas? I have to agree with BlueSkyIS. What happens if you print_r($_POST); before those two lines. Quote Link to comment https://forums.phpfreaks.com/topic/227279-processing-page-values/#findComment-1172560 Share on other sites More sharing options...
Xtremer360 Posted February 11, 2011 Author Share Posted February 11, 2011 Well how about this instead. Is there a better way to accomplish this. Quote Link to comment https://forums.phpfreaks.com/topic/227279-processing-page-values/#findComment-1172731 Share on other sites More sharing options...
Jessica Posted February 11, 2011 Share Posted February 11, 2011 Well how about this instead. Is there a better way to accomplish this. I guess taking advice and trying what people suggest, so they can help you, isn't a good way to solve it? Quote Link to comment https://forums.phpfreaks.com/topic/227279-processing-page-values/#findComment-1172815 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.