DeanWhitehouse Posted April 23, 2008 Share Posted April 23, 2008 with this code } if(isset($_POST['hideemail']) == 0) { mysql_query("UPDATE $user SET show_email = '0' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); } elseif(isset($_POST['hideemail']) == 1) { mysql_query("UPDATE $user SET show_email = '1' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); } echo "Settings Saved"; } its changing the show_email even when i don't tick either box, it shouldn't be doing this, it should only do this if it is ticked. Link to comment https://forums.phpfreaks.com/topic/102449-solved-check-box-problem-2/ Share on other sites More sharing options...
Northern Flame Posted April 23, 2008 Share Posted April 23, 2008 if(isset($_POST['hideemail']) == 0) that line makes no sense. try: } if(empty($_POST['hideemail'])) { mysql_query("UPDATE $user SET show_email = '0' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); } else { mysql_query("UPDATE $user SET show_email = '1' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); } echo "Settings Saved"; } Link to comment https://forums.phpfreaks.com/topic/102449-solved-check-box-problem-2/#findComment-524627 Share on other sites More sharing options...
DeanWhitehouse Posted April 23, 2008 Author Share Posted April 23, 2008 it still changes it Link to comment https://forums.phpfreaks.com/topic/102449-solved-check-box-problem-2/#findComment-524630 Share on other sites More sharing options...
Northern Flame Posted April 23, 2008 Share Posted April 23, 2008 oh you dont want it to change anything? try this then: } if(!empty($_POST['hideemail'])) { mysql_query("UPDATE $user SET show_email = '1' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); } echo "Settings Saved"; } Link to comment https://forums.phpfreaks.com/topic/102449-solved-check-box-problem-2/#findComment-524631 Share on other sites More sharing options...
DeanWhitehouse Posted April 23, 2008 Author Share Posted April 23, 2008 i still have the same problem Link to comment https://forums.phpfreaks.com/topic/102449-solved-check-box-problem-2/#findComment-524642 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 } if((isset($_POST['hideemail'])) && ($_POST['hideemail'] == 0)) { mysql_query("UPDATE $user SET show_email = '0' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); echo "Settings Saved"; } elseif((isset($_POST['hideemail'])) && ($_POST['hideemail'] == 1)) { mysql_query("UPDATE $user SET show_email = '1' WHERE user_id = '$user_id'")or die('Could not change settings: ' . mysql_error()); echo "Settings Saved"; } else { echo "Invalid hide email value."; } } Link to comment https://forums.phpfreaks.com/topic/102449-solved-check-box-problem-2/#findComment-524644 Share on other sites More sharing options...
DeanWhitehouse Posted April 23, 2008 Author Share Posted April 23, 2008 solved Link to comment https://forums.phpfreaks.com/topic/102449-solved-check-box-problem-2/#findComment-524646 Share on other sites More sharing options...
DarkWater Posted April 23, 2008 Share Posted April 23, 2008 My suggestion worked? Link to comment https://forums.phpfreaks.com/topic/102449-solved-check-box-problem-2/#findComment-524649 Share on other sites More sharing options...
DeanWhitehouse Posted April 23, 2008 Author Share Posted April 23, 2008 yer it did, Link to comment https://forums.phpfreaks.com/topic/102449-solved-check-box-problem-2/#findComment-525212 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.