anthonyreed Posted July 23, 2013 Share Posted July 23, 2013 Fairly new to PHP, so I am apologizing up front: Trying to get a couple check boxes to work when going to a MySQL database. They keep coming up "No" no matter what I do: Form Page: <?php if($_COOKIE['newsletter']=='No') echo ' <input type="checkbox" name="newsletterselect[]" value="newsletter" /><label class="Text"> Newsletters by Email </label>'; else echo '<input type="checkbox" name="newsletterselect[]" value="newsletter" checked /><label class="Text"> Newsletters by Email</label><br>'; ?> Processing Code: $newslettersselect[0]='No'; if(isset($_POST['newslettersselect'])){ foreach ($_POST['newslettersselect'] as $value){ if($value=='newsletters') $newslettersselect[0]='Yes'; } } setcookie("newsletters", $newslettersselect[0], null, "/", ".WEBSITENAMEHERE.com"); I have noticed that whenever I change the first line of the processing code (currently where it says 'No', that is the answer that shows up. If I change that to "yes", then I get "yes" in the database every time. Link to comment https://forums.phpfreaks.com/topic/280437-help-checkboxes-keep-showing-up-as-no-in-mysql-database/ Share on other sites More sharing options...
AbraCadaver Posted July 23, 2013 Share Posted July 23, 2013 Difference here: s value="newsletter" if($value=='newsletters') Link to comment https://forums.phpfreaks.com/topic/280437-help-checkboxes-keep-showing-up-as-no-in-mysql-database/#findComment-1441850 Share on other sites More sharing options...
anthonyreed Posted July 24, 2013 Author Share Posted July 24, 2013 Thanks AbraCadaver. Link to comment https://forums.phpfreaks.com/topic/280437-help-checkboxes-keep-showing-up-as-no-in-mysql-database/#findComment-1441923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.