Php/ HTML form help

what is wrong with my form submit code (it keeps returning failure):
html:

Send us a message




Message

php:

<?php $ToEmail = '[email protected]'; $EmailSubject = 'Site contact form'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comments"]).""; $MESSAGE_BODY .= "Phone: ".nl2br($_POST["phone"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?>

please help!

mail() is failing. Try using:

[php]error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1’)[/php]

Sorry I’m new to php. Where should I place the code?

Near the top of the page before the mail script.

it gave me syntax errors if i pit it anywhere but one place, and on that one place it doesn’t work

That code is to force the errors through, copy and paste the errors here so we can see.

i put the code on liones 2 and 3 and i got:

Parse error: syntax error, unexpected T_VARIABLE in /Applications/XAMPP/xamppfiles/htdocs/formSubmit1.php on line 4

it just stated that there was an error on the line after the code that was posted

Could you post the PHP code?

See my first post

Sorry for the slow reply. I ran the code and didn’t encounter a problem. Is there any other code on that page?

Note, I very slightly amended your code because I couldn’t be bothered creating 2 pages to test it:
[php]

<?php if(isset($_POST['submit'])){ $ToEmail = '[email protected]'; $EmailSubject = 'Site contact form'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comments"]).""; $MESSAGE_BODY .= "Phone: ".nl2br($_POST["phone"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); } else { ?>

Send us a message




Message

<?php } ?>[/php]

Really? You got it to email you? Is there a specific server type it has to be? Also, I have a ton of CSS that goes with the form, so I have to make the form in HTML, and then call the php in an action.

Sponsor our Newsletter | Privacy Policy | Terms of Service