View Single Post
Old 11-20-2004, 07:27 PM   #5 (permalink)
RelaX
Follower of Ner'Zhul
 
RelaX's Avatar
 
Location: Netherlands
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...
__________________
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents.
- Nathaniel Borenstein

Last edited by RelaX; 11-20-2004 at 07:37 PM..
RelaX is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76