Page 1 of 1

Contact Form Help

Posted: Tue Apr 22, 2008 11:38 pm
by arielpv1
Hello,

I have added a contact form to my website that requests the following fields:

Name(required)
Phone(required)
Email(required)
best time to call
time zone
comments

The problem is that, when I get the notification email telling me that I got a callback request,
MY email appear in the "from" field. Subject "Callback Request", and then, the major problem.

The body of the email is empty.

I get the names of the field in the email, but then the information entered is not sent in the email.

Basically, I just get a blank email from myself. With all the fields empty.

Here's the code:

***** PLEASE USE THE CODE OR PHP TAG WHEN POSTING *****

Code: Select all

<?php
if ($_POST['name'] != "" && $_POST['email'] && $_POST['best_phone'] ) {
$subject="CallBack Request";
$ip=$_SERVER["REMOTE_ADDR"];
$host = $ip;
$mon=date(m);
$day=date(j);
$year=date(y);
$hour=date(g);
$min=date(i);
$sec=date(s);
$hour=$hour-2;
if($hour<=0) { $hour+=12; }
$ts = "$hour:$min:$sec on $day/$mon/$year";
 
 
$to="ariel@thewealthpath.com";
 
$body="
 
Your Name = $name
 
Your Email = $email
 
Best Phone = $best_phone
 
Best Time To Call = $best_time_to_call
 
Your Time Zone = $your_time_zone
 
Comments = $comments
 
 
Host: $host
Time: $ts";
 
$email = "From: $name <$to>";
mail($to, $subject, $body, $email);
Header("Location: http://www.mysite.com/thankyou.html");
}
?>

Re: Contact Form Help

Posted: Wed Apr 23, 2008 12:51 am
by dhiraj
<?php
if ($_POST['name'] != "" && $_POST['email'] && $_POST['best_phone'] ) {
$subject="CallBack Request";
$ip=$_SERVER["REMOTE_ADDR"];
$host = $ip;
$mon=date(m);
$day=date(j);
$year=date(y);
$hour=date(g);
$min=date(i);
$sec=date(s);
$hour=$hour-2;
if($hour<=0) { $hour+=12; }
$ts = "$hour:$min:$sec on $day/$mon/$year";


$to="ariel@thewealthpath.com";

$body="

Your Name = $name

Your Email = $email

Best Phone = $best_phone

Best Time To Call = $best_time_to_call

Your Time Zone = $your_time_zone

Comments = $comments


Host: $host
Time: $ts";

$email = "From: $name <$to>";
mail($to, $subject, $body, $email);
Header("Location: http://www.mysite.com/thankyou.html");
}
?>
Above is your code i think ur coded have no problem but it have some i list here..

Your Name = $name=$_post['name'];

Your Email = $email=$_post['email'];

Best Phone = $best_phone =$_post['best_phone'];

Best Time To Call = $best_time_to_call =$_post['best_time_to_call'];

Your Time Zone = $your_time_zone=$_post['your_time_zone'];


Comments = $comments=$_post['comments'];


Host: $host and same for this ---
Time: $ts"; and same for this----- pick the value first.

$email = "From: $name <$to>";
now you use a php built in mail function and function is ....
@mail($to, $subject, "$comment\r\n", "From: $from\n" . "MIME-Version: 1.0\n" . "Content-type: text/html; charset=iso-8859-1\n" . 'X-Mailer: PHP/' . phpversion ());

try this one 8O :D

Re: Contact Form Help

Posted: Wed Apr 23, 2008 9:08 pm
by califdon
The problem is that you are using variables like $name to which your script has never assigned any values. The fact that they are in the $_POST[] array doesn't automatically create similarly named variables, you have to do that explicitly, such as:
$name = $_POST['name'];
$email = $_POST['email'];
... etc.