PDA

View Full Version : Php Mailer Form Help!



thewishmaster
May 30th, 2007, 10:33 PM
helo everyone, just got a problem with my code. actually i got it here kirupa tutorial about PHP mailer form. it doest work on me. i dont know what the errors are. kindly pls check?

MY CODE:
<?PHP
$to = "webmaster@site.com";
$subject = "Results from your Request Info form";
$headers = "From: Form Mailer";
$forward = 0;
$location = "";
$date = date ("l, F jS, Y");
$time = date ("h:i A");

$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";
if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for submitting our form. We will get back to you as soon as possible.";
}
?>

THIS IS THE ERROR:

it opens a pop up windows saying: do you want to download the file? the option buttons are: OPEN, SAVE, CANCEL.

its like downloading a file on the internet.

help please. thanks

thewishmaster.

J Trill
May 30th, 2007, 11:00 PM
$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";
if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else {

Thats the problem. Instead of displaying it, send it to their email.


<?php
if(isset($_POST['submit'])) {
//Assigning all the values
$to = "djdk904@gmail.com";
$subject = "Requesting a Quote";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$option = $_POST['radio'];
$dropdown = $_POST['drop_down'];

//What I'll see in the email.
$body = "From: $name_field\n E-Mail: $email_field\n $check_msg Option: $option\n Drop-Down: $dropdown\n Message:\n $message\n";

echo "Data has been submitted to $to!";
mail($to, $subject, $body);

} else {
echo "Your email was not sent! An error has occured.";
}
//Sends the user a confirmation
if (isset($_POST['submit'])) {

$email_field2 = $_POST['email'];
$subject2 = "Quote Confirmation";


$body2 = "Hello,\n Thank you for your request. We will get back to you as soon as possible!\n Thank you.";

mail($email_field2, $subject2, $body2);

echo "You have recieved a confirmation in your email.";

}

?>

rschoenbach
May 31st, 2007, 09:35 AM
THIS IS THE ERROR:

it opens a pop up windows saying: do you want to download the file? the option buttons are: OPEN, SAVE, CANCEL.

its like downloading a file on the internet.

help please. thanks

thewishmaster.

That error is mostly caused by a server that doesnt support PHP. Please check that your host supports PHP and mail().