1.

Solve : php email form Error?

Answer»

Can someone please tell me why this does not work ?




$formcontent = $_POST['name'] . ' would like some information.' . chr(10) . chr(13);
$formcontent .= 'their email is : ' . $_POST['email'] . chr(22)   . chr(24);

$formcontent .= ' Here is their Question  :  ' . $_POST['Question']   . chr(20) . chr(30) ;

$recipient = '[email protected]';
$subject = 'Website Form 2';

mail($recipient, $subject, $formcontent) or die('An error occurred while trying to send your e-mail, please notify Jo.');

echo "Thank You!";
?>

Thank you
Your Question has been sent.

click here to return to the Tooth Fairy homepage[/url]


also i USE the exsact same code on a diffrent website and it works fine ? i DONT understand ?Can you be more specific than "does not work"?  What result do you get?

While in development, you might find it useful to dump the contents of the $_POST variable, to see if it is receiving any data:

Code: [Select]<?php echo '<pre>'; print_r($_POST); echo '</pre>';  ?>
hello...i have tested your code:
the error i am getting is

Notice: Undefined index: name in C:\xampp\htdocs\a\a.php on line 3

Notice: Undefined index: email in C:\xampp\htdocs\a\a.php on line 4

Notice: Undefined index: Question in C:\xampp\htdocs\a\a.php on line 6

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\a\a.php on line 11
An error occurred while trying to send your e-mail, please notify Jo.


$formcontent = $_POST['name'] . ' would like some information.' . chr(10) . chr(13);  line 3

you i guess, your error is
$_POST['name']...when you are extracting name...its not able to get the variable "name" , "email" etc...

i THINK you should place your html code in the same file...for example
$formcontent = $_POST['name'] . ' would like some information.' . chr(10) . chr(13);
---
---
---
?>



---
---
--



else you should include the html file on top of your php

include ("a.html");
$formcontent = $_POST['name'] . ' would like some information.' . chr(10) . chr(13);
---
---
--
?>

please, im just giving you the guidelines...please refer to google for exact syntax and format for include...i forgot a bit about syntax...


Lina, the script is intended to receive data from another web page.  You will definitely get those errors if you try to run it on its own.yea...true...

silverpersian....give us ur exact error....

and your full code...are u able to extract the values at least after passing them from the other page??

Quote from: lina19 on January 07, 2012, 01:39:07 PM
are u able to extract the values at least after passing them from the other page??

That's why I wrote this:

Quote from: Rob POMEROY on January 06, 2012, 09:17:44 AM
While in development, you might find it useful to dump the contents of the $_POST variable, to see if it is receiving any data:

Code: [Select]<?php echo '<pre>'; print_r($_POST); echo '</pre>';  ?>

Let's wait for the OP to provide more info.ok thx..... Quote from: silverpersian on January 06, 2012, 06:16:37 AM
also i use the exsact same code on a diffrent website and it works fine ? i dont understand ?

Is your webserver running the latest version of PHP?
Quote from: Rob Pomeroy on January 06, 2012, 09:17:44 AM
Can you be more specific than "does not work"?  What result do you get?

While in development, you might find it useful to dump the contents of the $_POST variable, to see if it is receiving any data:

Code: [Select]<?php echo '<pre>'; print_r($_POST); echo '</pre>';  ?>

I have the exact same problem as Lina! I did use the
Code: [Select]<?php echo '<pre>'; print_r($_POST); echo '</pre>';  ?>
QUERY yet it gives me an empty array.

What can be the reason? Quote from: corrievm on January 25, 2012, 12:44:20 AM
What can be the reason?

The PHP page has received no POST data.  So the HTML form didn't send POST data.  Possibly the form's method is set to GET, which is usually a bad idea.

Also remember that the PHP page will only receive data from somewhere else.  If you just load that page up, the array will indeed be empty and that is just as you would expect.


Discussion

No Comment Found