[Noob] How to execute commands with checkbox arrays?
Posted: Mon Sep 13, 2010 3:16 pm
Hello!
My HTML form page looks like this:
I am having trouble with my php code (on testping.php, of course). I'm starting fresh with this:
This is all I want it to do:
There is an array of checkboxes and a submit button. I already know how to use the php mail function-- that's not the issue. I just don't know where to PUT that function.
Depending on who the end-user checks before pressing submit, an e-mail (same body/headers but a different $to address for each) needs to be sent out to those people. If all 5 people are checked, 5 separate e-mails are sent. If Person B and D are checked-- etc etc.
Any help would be appreciated. I feel like I tried everything.
Thanks!
My HTML form page looks like this:
Code: Select all
<form action="testping.php" method="post">
Who do you want to ping?<br />
<input type="checkbox" name="testPing[]" value="A" />Person A<br />
<input type="checkbox" name="testPing[]" value="B" />Person B<br />
<input type="checkbox" name="testPing[]" value="C" />Person C<br />
<input type="checkbox" name="testPing[]" value="D" />Person D<br />
<input type="checkbox" name="testPing[]" value="E" />Perseon E
<input type="submit" name="formSubmit" value="Submit" />
</form>Code: Select all
<?php
$aPing = $_POST['testPing'];
if(empty($aPing))
{
echo("You didn't select anyone.");
}
else
{
$N = count($aPing);
for($i=0; $i < $N; $i++)
{
echo($aPing[$i] . " ");
}
}
?>There is an array of checkboxes and a submit button. I already know how to use the php mail function-- that's not the issue. I just don't know where to PUT that function.
Depending on who the end-user checks before pressing submit, an e-mail (same body/headers but a different $to address for each) needs to be sent out to those people. If all 5 people are checked, 5 separate e-mails are sent. If Person B and D are checked-- etc etc.
Any help would be appreciated. I feel like I tried everything.
Thanks!