-Jim Posted March 27, 2009 Posted March 27, 2009 I got this PHP code off a site and its works great. But I added a new field called 'name' and I cant find out a way to include that field when the results are emailed to me. Right now, the only thing I get in the message field of my email is the $message. I tried adding, $message,$name but then I get an error and the email does note even get sent. What I want is for the email I get to include the $message and the $name fields. Right now it just includes the $message field $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $name = $_REQUEST['name']; mail( "[email protected]", "Form Results", $message, "From: $email" ); header( "Location: thankyou.html" ); ?>
kmount Posted March 27, 2009 Posted March 27, 2009 Hi Jim, This should suffice. Kim. $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $name = $_REQUEST['name']; mail( "[email protected]", "Form Results", "Name: $name\nMessage: $message", "From: $email" ); header( "Location: thankyou.html" ); ?> 1
powdarrmonkey Posted March 27, 2009 Posted March 27, 2009 $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $name = $_REQUEST['name']; mail( "[email protected]", "Form Results", $message, "From: $name <$email>" ); header( "Location: thankyou.html" ); ?> Other vague improvement: if( mail( "[email protected]", "Form Results", $message, "From: $name <$email>" )) { header( "Location: thankyou.html" ); } else { header("Location: sorrycouldntbedone.html"); } 1
-Jim Posted March 27, 2009 Author Posted March 27, 2009 It worked and I can easily follow it if I want to add more fields. thx
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now