Sorry for the dumb question, though I'm a little new to PHP. I've tried a lot of other ways to do this, but simply couldn't get this to work... Actually I want it to make it that I can have different functions attached to each checkbox that when a user selects a checkbox or another, and clicks the submit button, it triggers the specific functions. But I cannot get the checkboxes to work. It either works with only one selected, or if I check the 1st one then the 4th one, it outputs the 4th's code. Any other ways of doing this? Here is my attempt:
1.php
<form method="POST" action="2.php">
<input type="checkbox" name="test[]" value="test1" />test1<br />
<input type="checkbox" name="test[]" value="test2" />test2<br />
<input type="submit" name="submit" value="submit" />
</form>
2.php
$val = $_POST['test'];
if(isset($val)==true){
for($i = 0 ; $i<count($val) ; $i++){
if($val=='test1'){
echo $val;
die();
}elseif($val=='test2'){
echo $val;
die();
}else{
echo "fail";
die();
}
}
}else{
return false;
}
Thank you.