buggedout Posted August 28, 2015 Share Posted August 28, 2015 Hi all I am new with PHP and this simple thing has been driving me nuts. I finally got my contact form to work successfully thanks to tutorials around the internet. But I don't know what code to use so that I may view the name entered in the name field on the form, or have the email displayed how I would like it. Right now when I get the email, the from address is the email the person types in. OK. The message shows up just as an ordinary message without anything else... that works, but what I would like is for the email to arrive in this format: Name: (name) Email: (email address) Message: (message) right now only the message shows up in the email body. I would like to see everything in the email body. the name doesn't show up anywhere. I have tried a few different things but then I get error 500 when I submit the form. I know I am missing something simple. I have attached the code I am using. Wasn't able to copy and paste. Please help! sendmail.php Quote Link to comment https://forums.phpfreaks.com/topic/297968-quick-php-question-regarding-contact-form/ Share on other sites More sharing options...
ginerjm Posted August 28, 2015 Share Posted August 28, 2015 If you post your code perhaps we can help you. Quote Link to comment https://forums.phpfreaks.com/topic/297968-quick-php-question-regarding-contact-form/#findComment-1519832 Share on other sites More sharing options...
buggedout Posted August 28, 2015 Author Share Posted August 28, 2015 I added it as an attachment, as I indicated in my post. for some reason I am unable to paste it in here. Quote Link to comment https://forums.phpfreaks.com/topic/297968-quick-php-question-regarding-contact-form/#findComment-1519833 Share on other sites More sharing options...
ginerjm Posted August 28, 2015 Share Posted August 28, 2015 Well, some of us don't look at other sites. Can't imagine why you can't post code here. Quote Link to comment https://forums.phpfreaks.com/topic/297968-quick-php-question-regarding-contact-form/#findComment-1519834 Share on other sites More sharing options...
QuickOldCar Posted August 28, 2015 Share Posted August 28, 2015 <?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; mail( "admin@yoursite.com", "Feedback Form Results", $message, "From: $email" ); header( "Location: http://www.yoursite.com/thankyou.html" ); ?> Look at some mail examples from php.net Posting the code from your form could also help. Quote Link to comment https://forums.phpfreaks.com/topic/297968-quick-php-question-regarding-contact-form/#findComment-1519836 Share on other sites More sharing options...
buggedout Posted August 28, 2015 Author Share Posted August 28, 2015 Is there a reason why you can't open the attachment? I'm not asking you to go to another site. When I paste, nothing happens. I even tried the paste button. Seems to be some type of bug with the forum software. Quote Link to comment https://forums.phpfreaks.com/topic/297968-quick-php-question-regarding-contact-form/#findComment-1519838 Share on other sites More sharing options...
buggedout Posted August 28, 2015 Author Share Posted August 28, 2015 Thanks I'll take a look. Here is the form code (attached). Sorry, it won't let me paste. formcode.txt Quote Link to comment https://forums.phpfreaks.com/topic/297968-quick-php-question-regarding-contact-form/#findComment-1519839 Share on other sites More sharing options...
scootstah Posted August 28, 2015 Share Posted August 28, 2015 You'd have to do something like this: <?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $body = sprintf( "Name: %s\n\nEmail: %s\n\nMessage: %s", $name, $email, $message ); mail( "admin@yoursite.com", "Feedback Form Results", $body, "From: $email" ); header( "Location: http://www.yoursite.com/thankyou.html" ); Quote Link to comment https://forums.phpfreaks.com/topic/297968-quick-php-question-regarding-contact-form/#findComment-1519840 Share on other sites More sharing options...
buggedout Posted August 28, 2015 Author Share Posted August 28, 2015 ^Thanks, I will try that. The link posted above also has some extremely helpful information. I should be OK now. Thanks all! Quote Link to comment https://forums.phpfreaks.com/topic/297968-quick-php-question-regarding-contact-form/#findComment-1519843 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.