here is what I did when I needed a form that would send me new recipes from my site.
The action='email.php' sends the info in the for to the page email.php... that is not visible by the viewers.. it builds the email and sends it via the server that hosts your site.
It looks like this. note: the variables below in $MyArray[] match the name='your_field_name' fields from the form above.
reset ($_POST);
while(list($key, $val) = each ($_POST))
{
$MyArray[] = "$val";
}
$FirstName = $MyArray[0];
$Middle = $MyArray[1];
$LastName = $MyArray[2];
$EmailAddress = $MyArray[3];
$City = $MyArray[4];
$State = $MyArray[5];
$RecipeName = $MyArray[6];
$Category = $MyArray[7];
$Ingredients = $MyArray[8];
$Description = $MyArray[9];
$PrepTime = $MyArray[10];
$CookTime = $MyArray[11];
$email = $EmailAddress;
$message = "First Name:\r\n" . $FirstName . "\r\n\r\n" .
"Middle:\r\n" . $Middle . "\r\n\r\n" .
"Last Name: \r\n" . $LastName . "\r\n\r\n" .
"City:\r\n" . $City . "\r\n\r\n" .
"State:\r\n" . $State . "\r\n\r\n" .
"RecipeName:\r\n" . $RecipeName . "\r\n\r\n" .
"Category:\r\n" . $Category . "\r\n\r\n" .
"Ingredients:\r\n" . $Ingredients . "\r\n\r\n" .
"Description:\r\n" . $Description . "\r\n\r\n" .
"Prep Time:\r\n" . $PrepTime . "\r\n\r\n" .
"Cook Time:\r\n" . $CookTime . "\r\n\r\n";
if (
mail("webmaster@{$_SERVER['SERVER_NAME']}",
"New Recipe",
$message,
"From: $email\r\n" .
"Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n" .
"X-Mailer: PHP/" .
phpversion())
)
{ header("Location: http://www.yourdomain.com/thanks.php?redirect=true&firstname=$FirstName&lastname=$LastName"); }
else
{ header("Location: http://www.yourdomain.com/thanks.php?redirect=false"); }
?>
2006-12-19 22:09:25
·
answer #4
·
answered by HughH 1
·
0⤊
1⤋