louis_coetzee Posted January 12, 2009 Share Posted January 12, 2009 function LegalTerms() { extract($_REQUEST); echo $legal; //just to see the value echo $terms; // if ($legal !== 'yes') { echo 'You need to agree to the terms and must be of legal age if you want to register.'; }else { if ($terms !== 'yes') { echo 'You need to agree to the terms and must be of legal age if you want to register.'; } } } for some reason the value of both checkboxes checked or not, their value's stay "yes" this is the form:<div id="reg_form_box"> <input name="terms" type="checkbox" id="terms" value="yes"> I agree to the <a href="#" target="Terms">Terms Of Use.</a> <br> <input name="legal" type="checkbox" id="legal" value="yes"> I am of legal age to work in South Africa. </div> Please guys any help would be appreciated. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/140513-posting-checkbox-value-problem/ Share on other sites More sharing options...
ngreenwood6 Posted January 12, 2009 Share Posted January 12, 2009 First of all you don't need a function to do this. Secondly why dont you use the <form> if you are using a form. I would do something like this: index.php <form method="post" action="submit.php"> <input name="terms" type="checkbox" id="terms" value="yes"> I agree to the <a href="#" target="Terms">Terms Of Use.</a> <br> <input name="legal" type="checkbox" id="legal" value="yes"> I am of legal age to work in South Africa. <input type="submit" value="submit"> </form> submit.php <?php $terms = $_POST['terms']; $legal = $_POST['legal']; if($legal != 'yes') { echo "You need to agree to the terms and must be of legal age if you want to register."; } else { if($terms != 'yes') { echo "You need to agree to the terms and must be of legal age if you want to register."; } } ?> You would need to modify that for your needs. Link to comment https://forums.phpfreaks.com/topic/140513-posting-checkbox-value-problem/#findComment-735345 Share on other sites More sharing options...
louis_coetzee Posted January 12, 2009 Author Share Posted January 12, 2009 I am using ajax, still not working. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/140513-posting-checkbox-value-problem/#findComment-735387 Share on other sites More sharing options...
ngreenwood6 Posted January 12, 2009 Share Posted January 12, 2009 This should be moved to the ajax forum. Someone there will be able to answer your question better. Link to comment https://forums.phpfreaks.com/topic/140513-posting-checkbox-value-problem/#findComment-735407 Share on other sites More sharing options...
louis_coetzee Posted January 12, 2009 Author Share Posted January 12, 2009 thanks anyway Link to comment https://forums.phpfreaks.com/topic/140513-posting-checkbox-value-problem/#findComment-735536 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.