PHP Form Email Results
Posted: Tue Aug 16, 2011 11:27 am
Hello, new to php and trying to get a form working with checkbox items and email me the results.
I am using the script below, so instead of just displaying the user's selections, want to get them emailed to me.
I think I need to add some code like follows, but can't seem to get it working (also need to go to thankyou page after submitted). Any suggestions?
$my_email="(email address where results to be sent)";
mail( "$my_email", "Feedback Form Results",
$aDoor[$i]" );
header( "Location: $thankyou_page" );
}
Thanks!
I am using the script below, so instead of just displaying the user's selections, want to get them emailed to me.
Code: Select all
<?php
if(isset($_POST['formSubmit']))
{
$aDoor = $_POST['formDoor'];
if(isset($_POST['formWheelchair']))
{
echo("<p>You DO need wheelchair access.</p>\n");
}
else
{
echo("<p>You do NOT need wheelchair access.</p>\n");
}
if(empty($aDoor))
{
echo("<p>You didn't select any buildings.</p>\n");
}
else
{
$N = count($aDoor);
echo("<p>You selected $N door(s): ");
for($i=0; $i < $N; $i++)
{
echo($aDoor[$i] . " ");
}
echo("</p>");
}
}
?>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<p>
Which buildings do you want access to?<br/>
<input type="checkbox" name="formDoor[]" value="A" />Acorn Building<br />
<input type="checkbox" name="formDoor[]" value="B" />Brown Hall<br />
<input type="checkbox" name="formDoor[]" value="C" />Carnegie Complex<br />
<input type="checkbox" name="formDoor[]" value="D" />Drake Commons<br />
<input type="checkbox" name="formDoor[]" value="E" />Elliot House
</p>
<p>
Do you need wheelchair access?
<input type="checkbox" name="formWheelchair" value="Yes" />
</p>
<input type="submit" name="formSubmit" value="Submit" />
</form>$my_email="(email address where results to be sent)";
mail( "$my_email", "Feedback Form Results",
$aDoor[$i]" );
header( "Location: $thankyou_page" );
}
Thanks!