leachus2002 Posted August 13, 2010 Share Posted August 13, 2010 Hi Everyone, I am having problems when submitting a form that has check boxes within it (post.php). All the check boxes have a name and a checked value of 1 - the receiving page (for example submit.php) has the variables defined: $tickbox1 = $_POST['tickbox1']; The problem I am finding is that if the box isnt checked - I get an "index is not defined" error. I would suppose because there is no value. I have tried this before and it has worked, however that was on Apache and this is on IIS. Is there a work around? Thanks Matt Quote Link to comment https://forums.phpfreaks.com/topic/210626-problem-with-html-form-and-check-boxes/ Share on other sites More sharing options...
Wolphie Posted August 13, 2010 Share Posted August 13, 2010 $tickbox1 = array_key_exists('tickbox1', $_POST) ? 1 : 0; This basically checks to see if the 'tickbox1' key index has been set within the $_POST array. If it has, then set $tickbox1 to 1 (which it would be anyway), otherwise set it to zero if it hasn't been set. Quote Link to comment https://forums.phpfreaks.com/topic/210626-problem-with-html-form-and-check-boxes/#findComment-1098805 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.