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!';

?>
Member Avatar for brewbuff

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

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

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.