Jump to content

PHP form - stops user proceeding until they have ticked checkboxes


annette50

Recommended Posts

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

<?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";
}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.