PHP help - EMailing

PoonDaddy007

Senior member
Dec 17, 2000
246
0
0
I have a page that has variables listed on it already. And I want to have those values sent thru email to me.

Quick breakdown:

Page 1 -> User enters in various information [name, address, email, etc]. I have those values entered into text fields and have them passed to page 2 with names like $FNAME, $LNAME, $ADDRESS, etc. when the user hits submit.

Page 2 -> Echos what user inputs on page1 making sure all the entered information is correct sort of like a confirmation page before submitting again. When the user hits submit I want the values to be emailed to me.

How do I go about doing this?

Thanks.
 

numark

Golden Member
Sep 17, 2002
1,005
0
0
Variables are passed to the second script with the name given to the form element, e.g.:

< input type="radio" name="button" >

will be passed to the script as $button (unless register_globals aren't on, then you reference it by saying $button = $_POST["button"] if using the POST method, or $button = $_GET["button"] if using GET).

Then just format the variables however you want into one variable, e.g.:

$mailthis = "The user $user said $whathesaid and can be contacted at $hisemail";

and do:

mail($youremail, "Subject goes here", $mailthis)

Might be a good idea to filter out HTML using $whathesaid = strip_tags($whathesaid) so you don't get any HTML emails with inappropriate or other such nonsense content.

Edit: Small correction to the mail() statement, forgot that you wanted the output mailed to you, not the person that submitted the information.