php email whole page

the mail() function

Moderators: macek, egami, gesf

Post Reply
bhenry

php email whole page

Post by bhenry » Mon Feb 06, 2006 8:33 am

Sorry if this question seems basic i am fairly new to php. i have a html form that when completed it sends them to a php page for them to verify the information. I am trying to make a link at the bottom of the php page that will e-mail the entire page to me. any help would be greatly appreciated.

bhenry

Post by bhenry » Tue Feb 07, 2006 12:06 pm

Update: I can send the page as a link, but because of the nature of the page when the link is selected it the input data is not there. The best solution would be to have the page embeded into the body of the e-mail. I though a link to the pages I am working on might be helpful h1.ripway.com/bhenry/consent1.html

User avatar
gesf
Moderator
Moderator
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden
Contact:

Post by gesf » Tue Feb 07, 2006 12:34 pm

You need to send the gererated data (after submittion)... right ? So... that's all you need to do!

bhenry

Post by bhenry » Tue Feb 07, 2006 12:43 pm

I need the generated data i.e. user imputs, but i also need the legal language that is at the top of the page.

Coditor
New php-forum User
New php-forum User
Posts: 243
Joined: Wed Feb 01, 2006 9:18 am
Location: Netherlands
Contact:

Post by Coditor » Tue Feb 07, 2006 12:45 pm

If you really want to send the exact page, I suggest you use this:

Code: Select all

<?php
ob_start();
?>
<html>
<body>
Build your page here...
</body>
</html>
<?php
$pageContent = ob_get_clean();
echo $pageContent;
mail("me@myemail.com", "form submit", $pageContent, "Content-type: text/html\n");
?>

bhenry

Post by bhenry » Tue Feb 07, 2006 1:10 pm

Coditor- Where would I put the submit button? Do i change the form action to mailto?

Coditor
New php-forum User
New php-forum User
Posts: 243
Joined: Wed Feb 01, 2006 9:18 am
Location: Netherlands
Contact:

Post by Coditor » Tue Feb 07, 2006 1:58 pm

This would work without a submit button. It would e-mail the data to you as soon as the user sees the resultpage.

If you really want to use a submit button, add hidden fields for all the data and an extra hidden field (eg <input type="hidden" name="printthis" value="yes" />) and submit again to the same page as you are.

Change line 13 to:

Code: Select all

if (isset(_POST{"printthis"}) && _POST{"printthis"} == "yes") {
   mail("me@myemail.com", "form submit", $pageContent, "Content-type: text/html\n");
}

Post Reply

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest