retrieving ALL fields from a form in an email
Posted: Thu Aug 30, 2007 5:58 pm
I have tried to no avail to get the code to work where as when the form is submitted and sent to the email it places in the email all the information from the fields that was submitted. For example: the form contains
Name
Phone
Email
a selection from two drop down lists
a selection from radio buttons, and
comments
Here is the initial code I used, but it only returned the variable "phone" or "comments" whichever I entered.
I then tried this code, which is suppose to return all fields in a form with the email, but this one returns the redirected page, Thank you, but never sends the email.
<?php
$to = "info@c1realty.com";
$subject = "Maintenance Request";
$message = "";
$from = trim(strip_tags($_REQUEST['email']));
foreach($_REQUEST as $key => $val)
{
$message .= $key .": ". trim(strip_tags($val)) ."\n";
}
if( !mail($to, $subject, $message, "From: $from")) {
header("Location: http://www.c1realty.com/temp/error.htm");
}
else {
header("Location: http://www.c1realty.com/temp/thanks.htm");
?>
Can someone take a look and see what I am missing or what I have done wrong. From all the posts, scripts and forums and yes tutorials I have read, I can't seem to get this to work. Thanks
Vienie
[/syntax]
Name
Phone
a selection from two drop down lists
a selection from radio buttons, and
comments
Here is the initial code I used, but it only returned the variable "phone" or "comments" whichever I entered.
Code: Select all
[syntax=php]<?php
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$phone = $_REQUEST['phone'] ;
if (!isset($_REQUEST['email'])) {
header( "Location: http://www.c1realty.com/temp/pm/lfm.htm" );
}
elseif (empty($name) || empty($phone) || empty($email)) {
header( "Location: http://www.c1realty.com/temp/error.htm");
}
else {
mail( "info@c1realty.com", "Manager Form Results",
$phone, "From: $name <$email>" );
header( "Location: http://www.c1realty.com/temp/thanks.htm" );
}
?><?php
$to = "info@c1realty.com";
$subject = "Maintenance Request";
$message = "";
$from = trim(strip_tags($_REQUEST['email']));
foreach($_REQUEST as $key => $val)
{
$message .= $key .": ". trim(strip_tags($val)) ."\n";
}
if( !mail($to, $subject, $message, "From: $from")) {
header("Location: http://www.c1realty.com/temp/error.htm");
}
else {
header("Location: http://www.c1realty.com/temp/thanks.htm");
?>
Can someone take a look and see what I am missing or what I have done wrong. From all the posts, scripts and forums and yes tutorials I have read, I can't seem to get this to work. Thanks
Vienie
[/syntax]