rofl90 Posted March 15, 2008 Share Posted March 15, 2008 How do you validate checkbox's/select? Do you have to get all values.. but in radios they all have to have the same name so hw do you validate the single one. thanks, charlie Quote Link to comment https://forums.phpfreaks.com/topic/96252-validating-checks-select-radios/ Share on other sites More sharing options...
p2grace Posted March 15, 2008 Share Posted March 15, 2008 What exactly are you trying to validate when it comes to the radios? Whether or not they selected one? You could just select one by default and then have them change it, that way you don't have to validate whether or not it was checked. Quote Link to comment https://forums.phpfreaks.com/topic/96252-validating-checks-select-radios/#findComment-492723 Share on other sites More sharing options...
sKunKbad Posted March 15, 2008 Share Posted March 15, 2008 use the in_array() function, and have php check that the value of the checkbox or radio button is an acceptable value. Here is an example from a form on my website. $approx_pagesArray = array("1","2","3","4","5","6-10","11-15","16+","dont_know"); if(in_array("{$_POST['approx_pages']}", $approx_pagesArray)){ $approx_pages = urlencode($_POST['approx_pages']); } Quote Link to comment https://forums.phpfreaks.com/topic/96252-validating-checks-select-radios/#findComment-492725 Share on other sites More sharing options...
rofl90 Posted March 16, 2008 Author Share Posted March 16, 2008 By validating, I meant like for a select, radio, and checks how do you validate eg with text and pw etc u use $user = $_POST['user']; Quote Link to comment https://forums.phpfreaks.com/topic/96252-validating-checks-select-radios/#findComment-493509 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.