Jump to content

php email header


dgow13

Recommended Posts

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?

Link to comment
Share on other sites

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

?>

Link to comment
Share on other sites

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 by dgow13
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...