eurob Posted December 29, 2007 Share Posted December 29, 2007 part of my html <form action="process.php" method="post"> Check box field: <input name="showit[]" type="checkbox" value="whatever"> <input type="submit"> //process.php <?php $showit = $_POST['showit'] ?> If I don't check the check box I get the error 'undefined index'. How can I still capture the check box value, regardless if I checked it or not? Thanks, robert Quote Link to comment https://forums.phpfreaks.com/topic/83550-check-box-question/ Share on other sites More sharing options...
PHP_PhREEEk Posted December 29, 2007 Share Posted December 29, 2007 process.php <?php if ( isset($_POST['showit']) ) { $showit = $_POST['showit'] } Undefined index is only a notice, nothing fatal. You can ignore those, but if you want to program correctly, you need to test if a variable exists before working with it directly. PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/83550-check-box-question/#findComment-425104 Share on other sites More sharing options...
eurob Posted December 30, 2007 Author Share Posted December 30, 2007 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/83550-check-box-question/#findComment-425683 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.