dgow13 Posted January 21, 2010 Report Share Posted January 21, 2010 After setting up my contact form and making sure it works properly, I still have not discovered how to change the line at the top of the email that states who is submitting the email. It should have the senders email but it does not. Here is how it looks. From: mbiweb13@p3nlh174.shr.prod.phx3.secureserver.net To: dgow@simplewebs13.com cc: Subject: Text The "From" line should contain the senders email once they fill out the form and then submit it. Any suggestions? Quote Link to comment Share on other sites More sharing options...
falkencreative Posted January 21, 2010 Report Share Posted January 21, 2010 If you want help with this, I'd suggest posting the code so we have an idea of what you are working with. Quote Link to comment Share on other sites More sharing options...
dgow13 Posted January 21, 2010 Author Report Share Posted January 21, 2010 Here is the code from the contact us page: Website Design and Development Graphic and Logo Designs Animation Web Hosting Domain Name Registration Search Engine Optimization Business Card Print Media Designs General Questions Code from the thank you page: <?php //php form data to email code// $first_name = $_REQUEST['first_name']; $last_name = $_REQUEST['last_name']; $email = $_REQUEST['email']; $phone = $_REQUEST['phone']; $radio = $_REQUEST['radio']; $message = $_REQUEST['message']; $email_message = "First Name: {$first_name}\n\rLast Name: {$last_name}\n\rEmail: {$email}\n\rPhone: {$phone}\n\rInterested In: {$radio}\n\rMessage: {$message}"; mail('dgow@simplewebs13.com',$radio,$email_message); ?> Quote Link to comment Share on other sites More sharing options...
falkencreative Posted January 21, 2010 Report Share Posted January 21, 2010 See example #2 here: http://php.net/manual/en/function.mail.php Basically, you need to add email headers that indicate who sent the message. The example on PHP.net is pretty simple and straightforward. Quote Link to comment Share on other sites More sharing options...
dgow13 Posted January 24, 2010 Author Report Share Posted January 24, 2010 (edited) I have tried your suggestion from example 2 and it did not work. I am doing something wrong. Underneath the $message... I put the following; $headers = 'From: $email'; I have tried it different ways but when the email is sent I get From: $email@p3nlh174.shr.prod.phx3.secureserver.net. No matter what I try the part after the @ sign always appears. I know I am not coding something right. Edited January 24, 2010 by dgow13 Quote Link to comment Share on other sites More sharing options...
falkencreative Posted January 24, 2010 Report Share Posted January 24, 2010 If I remember correct, PHP doesn't insert variable values when you use single quotes. I'd suggest trying $headers = "From: $email"; and make sure you add $headers to your mail line: mail($to, $subject, $message, $headers); Quote Link to comment Share on other sites More sharing options...
dgow13 Posted January 24, 2010 Author Report Share Posted January 24, 2010 Perfect !!! It worked. I guess you can't use single quotes. They have to be double quotes in php. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted January 24, 2010 Report Share Posted January 24, 2010 Perfect !!! It worked. I guess you can't use single quotes. They have to be double quotes in php. It's all in how PHP parses strings. Take this example: $var = "test"; echo "this is a $var"; echo 'this is a $var'; The first echo will display "this is a test", since PHP will insert the values of variables placed within the string. The second echo, however, will display "this is a $var" since it uses single quotes, and PHP doesn't look for variables within strings that use single quotes. Quote Link to comment Share on other sites More sharing options...
dgow13 Posted January 24, 2010 Author Report Share Posted January 24, 2010 That makes since. Every item or text I put in the single quotes displayed that text in the email header. Once I use double quotes it seemed to enable the php script. I am new to php. I am trying to learn and have subscribed to the killer university. I am watching as many videos as I can about the subjects I am trying to use on my clients sites. The next thing I need to learn is how to structure the email format so that it appears in the email like this: Name: Name text Email: Email text Phone: Phone text and so on... Quote Link to comment Share on other sites More sharing options...
administrator Posted January 24, 2010 Report Share Posted January 24, 2010 The next thing I need to learn is how to structure the email format so that it appears in the email like this: The easiest way is to use heredoc. Stefan Quote Link to comment Share on other sites More sharing options...
administrator Posted January 24, 2010 Report Share Posted January 24, 2010 I am trying to learn and have subscribed to the killer university. BTW, thanks for subscribing to the university. Stefan Quote Link to comment Share on other sites More sharing options...
dgow13 Posted January 24, 2010 Author Report Share Posted January 24, 2010 The university has opened up a whole new area for me. And a renewed enjoyment for building websites. Thanks for sharing your videos. Quote Link to comment 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.
Note: Your post will require moderator approval before it will be visible.