954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php email form

i have an email form and it wont work. i have made sure the email is correct and is working, but i keep getting the 'or die' error. Please help. here is the code:

<?php
$to = "****@***********.com";
$subject = "Contact Us";
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email";
$send = mail($to, $name, $subject, $message, $headers)
or die('Could Not Send');
echo'Sent!';

?>
tcollins412
Junior Poster
139 posts since Dec 2010
Reputation Points: 10
Solved Threads: 3
 

Try removing "$name," from call to mail function. (see the manual)

brewbuff
Newbie Poster
11 posts since Oct 2008
Reputation Points: 10
Solved Threads: 3
 

The format for the mail statement is:

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

You have one too many parameters for your mail statement ($name)

If you don't have a copy of the php manual, you should download one.

Chris

chrishea
Nearly a Posting Virtuoso
1,429 posts since Sep 2008
Reputation Points: 210
Solved Threads: 230
 

Please test it:

<?php
$to = "****@***********.com";
$subject = "Contact Us";
$name = $_REQUEST['name'] ;
$email = $_REQUEST['email'] ;
$message = $name . $_REQUEST['message'];
$headers = "From: $email";
if(@mail($to, $subject, $message, $headers))
{
echo "Your mail sent";
}
else
{
echo 'Error on sending';
}
?>


'@' return true or false!

mail function gets 4 options!

M0rteza
Junior Poster in Training
62 posts since Apr 2010
Reputation Points: 11
Solved Threads: 4
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: