Jump to content

Small PHP email issue


danp2010

Recommended Posts

Hi Guys, I have a small issue with a new php script I wrote.  It works fine, except for one issue.  When the scrip emails me the info it captures, I need it to have the email sent to me from the person filling out the form.  i.e.  from the email address located in the $email field.  It does not.  Here's the code. (domain.com is just a dummy name to hold the spot, obviously.)

 

<?php

 

/* Subject and email */

 

$emailSubject = 'Centre Street Registration';

$webMaster = 'email@domain.com';

 

/* Gathering Data */

 

$firstname = $_POST['FirstName'];

$lastname = $_POST['LastName'];

$email = $_POST['Email'];

$daytime = $_POST['Daytime'];

$home = $_POST['Home'];

$citytown = $_POST['CityTown'];

$movingwhen = $_POST['MovingWhen'];

$hearofus = $_POST['HearofUs'];

$contactmethod = $_POST['ContactMethod'];

$squareft = $_POST['SqareFt'];

$important = $_POST['Important'];

$pricerange = $_POST['PriceRange'];

 

$body = <<<EOD

 

 

First Name: $firstname

Last Name: $lastname

Email: $email

Daytime Number: $daytime

Home Number: $home

City: $citytown

Moving When: $movingwhen

Hear of Us: $hearofus

Contact Method: $contactmethod

Square Feet: $squareft

Important to You: $important

Price Range: $pricerange

 

Excel Data: $firstname,$lastname,$email,$daytime,$home,$citytown,$movingwhen,$hearofus,$contactmethod,$squareft,$important,$pricerange

EOD;

 

$headers = "From: $email";

$headers .= "Conten-type: text/html";

$success = mail($webMaster, $emailSubject, $body);

 

/* Results rendered as HTML */

 

/* $theResults = 'domain.com'; */

 

header( "Location: http://www.dommain.com/thankyou_centre.shtml" );

 

?>

 

Link to comment
Share on other sites

Check the name of the email field in the form, make sure it matches (caps and all).

Are the rest of the variables being populated?

 

Also, you're not including the $headers variable in the mail() function, not sure if you noticed

Link to comment
Share on other sites

I need it to have the email sent to me from the person filling out the form.

 

No, you don't. It is your mail server that is sending the email to you. The From: address must be a valid mail box at the sending mail server. You would want to put the visitor's entered email address into the Reply-to: address in the header.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.