Jump to content

Submit Form to an email


elham25

Recommended Posts

I have a form in the follwoing link:

http://isupportentourage.dyndns.info//CARES/application.htm

 

I would like to send the inputs to an email address so I have used a php file called sendEmail.php which has the following code:

 

<?php

 

$redirectTo = "http://www.yahoo.com";

$to = "[email protected]";

 

$subject = "Form Submission";

$headers  = "From:\r\n";

 

$message = "";

$formFields = array_keys($_POST);

 

for ($i = 0; $i < sizeof($formFields); $i++)

{

$theField = strip_tags($formFields[$i]);

$theValue = strip_tags($_POST[$theField]);

$message .= $theField;

$message .= " = ";

$message .= $theValue;

$message .= "\n";

}

 

$success = mail($to, $subject, $message, $headers);

if ($success)

{

header("Location: " . $redirectTo);

}

else

{

echo "An error occurred when sending the email.";

}

 

 

?>

Could someone tell me why it is not working at all.

 

 

Link to comment
https://forums.phpfreaks.com/topic/214221-submit-form-to-an-email/
Share on other sites

What is it doing? Does it redirect you to Yahoo! or does it echo that an error has occurred?

 

I'm guessing that the script does in fact redirect you to Yahoo! and if you were to look through your server logs you would find that it also dispatched the email. My guess is that Google is simply blocking the email due to it's lack of proper headers.

 

Hope this helps

I get redirected to a page with a message on top.

the message says:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/CARES/sendMail.php:2) in /var/www/CARES/sendMail.php on line 27

 

and no i don't get redirected to yahoo.

should i use another email?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.