0

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 ;).

2
Contributors
2
Replies
10
Views
5 Years
Discussion Span
Last Post by Red Dragon
0
$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";
 }

Edited by Biiim

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.