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 = "fatemeh.elmi@gmail.com";

 

$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
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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.