PHP Code:
<?
//Recipe box emailer
$submitter = $_POST["submitter"];
$rectitle = $_POST["title"];
$instructions = $_POST["instructions"];
$Form_date= date ("l, F d, Y H:i");
$Form_email= "anemail@adomain.net";
$Form_headers= "From:anotheremail@adomain.net";
$Form_emailsubject= "Submitted Recipe";
for($counter=0;$counter<=14;$counter++)
{
if ($_POST['ingredient'.$counter]
&& $_POST["amt".$counter]
&& $_POST["size".$counter])
{
$ingredientList.= $counter.". "$_POST["amt".$counter]." ".$_POST["size".$counter]." of "$_POST['ingredient'.$counter]."\n";
}
}
$Form_message= "
Submitter: $submitter \n
Recipe: $rectitle \n
Ingredient List: \n
$ingredientList
Instructions: \n$instructions \n";
mail ($Form_email, $Form_emailsubject, $Form_message, $Form_headers);
header ("Location:http://www.somesite.com/");
?>
Then just name your input fields 'ingredientlist1','ingredientlist2'... etc..
Why make your life difficult by making the postvars into an array and then going with a foreach or stuff when you can just let PHP take care of it? Of course if the page you use to submit these things is the same as this php page you could even let PHP handle the adding of the input boxes to the HTML page.
I do this for a living...
