kurt.santo Posted May 6, 2008 Share Posted May 6, 2008 I am testing if the terms have been accepted via a tickbox, but it does not work. The conditional check is: if (!isset($_POST['termsYes']) OR empty($_POST['termsYes'])) { $termsYes = FALSE; $errors['termsYes'] = 'Accept terms and conditions'; } else { $termsYes = TRUE; } with the tickboxes as: <?php echo check_error('termsYes', 'Accept terms and conditions*:'); ?> <label for="termsYes">Yes</label> <input type="radio" name="terms" value="termsYes" id="termsYes" /> <label for="termsNo">No</label><input type="radio" name="terms" value="termsNo" id="termsNo" /> Where am I going wrong? After submitting it always shows me that the tickbox has not been selected...Kurt Link to comment Share on other sites More sharing options...
Ingolme Posted May 6, 2008 Share Posted May 6, 2008 The name of the field is "terms", not "temsYes".So to access it, use $_POST['terms']And a radio button always returns its value if selected.Instead of: if (!isset($_POST['termsYes']) OR empty($_POST['termsYes']))Tryif ($_POST['terms'] != "termsYes") Link to comment Share on other sites More sharing options...
kurt.santo Posted May 6, 2008 Author Share Posted May 6, 2008 The name of the field is "terms", not "temsYes".So to access it, use $_POST['terms']And a radio button always returns its value if selected.Instead of: if (!isset($_POST['termsYes']) OR empty($_POST['termsYes']))Tryif ($_POST['terms'] != "termsYes") Great, Ingolme! Usingif (!isset($_POST['terms']) OR ($_POST['terms'] != "termsYes")) does the trick (checking if field is set and if yes, if it is set to termsYes). Was not aware that you cannot directly access each individual radio button via $_POST. Each day sth new;-)Cheers,Kurt Link to comment Share on other sites More sharing options...
boen_robot Posted May 6, 2008 Share Posted May 6, 2008 Was not aware that you cannot directly access each individual radio button via $_POST. Each day sth new;-)As a side note, PLEASE, learn to use var_dump() and print_r() to at least try to do some self debugging. If you ever have any form problems, just do:var_dump($_POST); at the top of the PHP code to see what was submitted, and work out the problem from there. Do the same for other superglobals ($_GET, $_COOKIE, etc.) if you use them in the code. Link to comment Share on other sites More sharing options...
kurt.santo Posted May 6, 2008 Author Share Posted May 6, 2008 As a side note, PLEASE, learn to use var_dump() and print_r() to at least try to do some self debugging. If you ever have any form problems, just do:var_dump($_POST); at the top of the PHP code to see what was submitted, and work out the problem from there. Do the same for other superglobals ($_GET, $_COOKIE, etc.) if you use them in the code. Thanks for your input. Put a big print out of your post on my desk, so I will be reminded;-)Kurt Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.