Hi, i'm just trying to make a simple 'contact us' form which emails me with the contents of each form field, here's what i have:

HTML
--------

<form action="contact.php" method="post" name="contact">
*Full Name<br />
<input name="name" type="text" /><br /><br />
*Email:<br />
<input name="email" type="email" /><br /><br />
*Message:<br />
<textarea name="msg" rows="10" cols="30"></textarea><br /><br />
<input name="reset" type="reset" value="Reset Fields" /><br />
<input name="submit" type="submit" value="Send Email" /><br />
</form>

PHP (contact.php)

<?php
$to = "myemail@domain.com";
$subject = "Contact Form Posting";
$message = "From: " $_POST['name'] "<" $_POST['email'] "> \n" $_POST['msg'];

$mail($to, $subject, $message);

if($mail){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

I assume the problem is with the line beginning "$message = ..." all my editor says is that there is an error....with no further details so i dunno what the problem is. There may be other errors in this too but i don't know php well enough to see them so any help would be appreciated. Also before anyone asks, the email address in my code is my actual email address ;).

$to = "myemail@domain.com";
$subject = "Contact Form Posting";
$additional_headers = "From: ".$_POST['name']." <".$_POST['email']."> \r\n";
//use . to concatenate strings/variables together
$message = $_POST['msg'];

//no $ in front of mail, it's a function
if(mail($to, $subject, $message,$additional_headers)){
 echo "We've recived your contact information";
 }
 else {
 echo "ERROR";
 }
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.