chris_rulez001 Posted July 25, 2007 Share Posted July 25, 2007 hi im making a forum hosting sevice, and i would like to know how do i make it so if the checkbox is unticked they cant register. heres what i have: <?php $tos = $_POST['tos']; if ($tos == "Unchecked" || $tos == "") { //the code carries on is the above how you would check if the checkbox is unticked? Link to comment https://forums.phpfreaks.com/topic/61745-form-validating/ Share on other sites More sharing options...
pedrobcabral Posted July 25, 2007 Share Posted July 25, 2007 if the checkbox is diferent from "on" it is not ticked. Link to comment https://forums.phpfreaks.com/topic/61745-form-validating/#findComment-307418 Share on other sites More sharing options...
chris_rulez001 Posted July 25, 2007 Author Share Posted July 25, 2007 if the checkbox is diferent from "on" it is not ticked. i dont understand what you mean Link to comment https://forums.phpfreaks.com/topic/61745-form-validating/#findComment-307430 Share on other sites More sharing options...
teng84 Posted July 25, 2007 Share Posted July 25, 2007 use the isset if (isset($_POST['chk'])){ then do anything here } Link to comment https://forums.phpfreaks.com/topic/61745-form-validating/#findComment-307432 Share on other sites More sharing options...
pedrobcabral Posted July 25, 2007 Share Posted July 25, 2007 Right, you just want also to put a ! before the word "isset". Link to comment https://forums.phpfreaks.com/topic/61745-form-validating/#findComment-307440 Share on other sites More sharing options...
chris_rulez001 Posted July 25, 2007 Author Share Posted July 25, 2007 ok thanks both of you for your help Link to comment https://forums.phpfreaks.com/topic/61745-form-validating/#findComment-307444 Share on other sites More sharing options...
redarrow Posted July 25, 2007 Share Posted July 25, 2007 try this to get the concept correct ok. <?php if(isset($_POST['submit'])){ if(empty ($one)){ echo "<br><br>unchecked 1<br><br>"; }else{ echo "<br><br>checked 1<br><br>"; } if(empty ($two)){ echo "<br><br>unchecked 2<br><br>"; }else{ echo "<br><br>checked 2<br><br>"; } if(empty ($three)){ echo "<br><br>unchecked 3<br><br>"; }else{ echo "<br><br>checked 3<br><br>"; } if(empty ($four)){ echo "<br><br>unchecked 4<br><br>"; }else{ echo "<br><br>checked 4<br><br>"; } } ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <br><br> check box 1 <input type="checkbox" name="one"> <br><br> check box 2 <input type="checkbox" name="two"> <br><br> check box 3 <input type="checkbox" name="three"> <br><br> check box 4 <input type="checkbox" name="four"> <br> <br> <input type="submit" name="submit" value="cheek"> </form> Link to comment https://forums.phpfreaks.com/topic/61745-form-validating/#findComment-307456 Share on other sites More sharing options...
rlindauer Posted July 25, 2007 Share Posted July 25, 2007 Wouldn't your example require register globals to be enabled? Link to comment https://forums.phpfreaks.com/topic/61745-form-validating/#findComment-307473 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.