annette50 Posted August 18, 2007 Share Posted August 18, 2007 Hi, I'm sure this should be really easy! I need a simple form where the user has to agree to the terms and conditions - if they do (by checking a checkbox) they can proceed to the next page. If not, the page redirects to the submit form again with a reminder. Very new at PHP so any help appreciated while I go through some tutorials! Annette Link to comment https://forums.phpfreaks.com/topic/65618-php-form-stops-user-proceeding-until-they-have-ticked-checkboxes/ Share on other sites More sharing options...
marcus Posted August 18, 2007 Share Posted August 18, 2007 <?php if(!$_POST['submit']){ echo "<form name=\"name\" method=\"post\" action=\"thispage.php\">\n"; echo "<table border=0 cellspacing=3 cellpadding=3>\n"; for($i=1;$i<=10;$i++){ echo "<tr><td>Checkbox $i</td><td><input type=\"checkbox\" name=\"list[]\" name=\"$i\"></td></tr>\n"; } echo "<tr><td colspan=2 align=right><input type=\"submit\" name=\"submit\" value=\"Submit\"></td></tr>\n"; echo "</table></form>\n"; }else { $list = $_POST['list']; if($list){ foreach($list AS $ids){ echo $ids . "<br>\n"; } }else { echo "No checkboxes ticked!\n"; } } ?> Link to comment https://forums.phpfreaks.com/topic/65618-php-form-stops-user-proceeding-until-they-have-ticked-checkboxes/#findComment-327668 Share on other sites More sharing options...
annette50 Posted August 18, 2007 Author Share Posted August 18, 2007 Wow that was quick, thank you. I have it working, however I get an error: "Notice: Undefined index: submit". Even though it is within an if? Link to comment https://forums.phpfreaks.com/topic/65618-php-form-stops-user-proceeding-until-they-have-ticked-checkboxes/#findComment-327673 Share on other sites More sharing options...
marcus Posted August 18, 2007 Share Posted August 18, 2007 try removing the single quotes Link to comment https://forums.phpfreaks.com/topic/65618-php-form-stops-user-proceeding-until-they-have-ticked-checkboxes/#findComment-327675 Share on other sites More sharing options...
annette50 Posted August 18, 2007 Author Share Posted August 18, 2007 Hi, Thanks for this - when I uploaded it my server it worked fine - must be something on localhost stopping it. Really grateful, Annette Link to comment https://forums.phpfreaks.com/topic/65618-php-form-stops-user-proceeding-until-they-have-ticked-checkboxes/#findComment-327677 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.