开发者

PHP mail entire page

开发者 https://www.devze.com 2023-02-14 13:43 出处:网络
I have a page that determines the variable ISSET and then acts on instructions. For example if the isset contains \'print\' it loads a file via Include Template Path and echos a code on the bottom tha

I have a page that determines the variable ISSET and then acts on instructions. For example if the isset contains 'print' it loads a file via Include Template Path and echos a code on the bottom that prints the window.

eg.

if (isset(开发者_开发技巧$_GET['quoteprint'])) {
include(TEMPLATEPATH . '/bookings/booking-quote.php');
echo'<script type="text/javascript">window.print()</script>';
}

Now I would like a similar function to exist but this time to email the contents of that page to the user. I tired this but it does not work. I think the content needs to be converted but I don't know where to start.

else if (isset($_GET['quoteemail'])) {
    $emailer = include(TEMPLATEPATH . '/bookings/booking-quote.php');
    $to = $current_user->user_email;
  $subject = "Your Quote - Dive The Gap" ;
  $message = $emailer;
  $headers = "From: Dive The Gap Bookings <ask@divethegap.com>" . "\r\n" .
             "Content-type: text/html" . "\r\n";

  mail($to, $subject, $message, $headers);
}

Any ideas?

Marvellous


The include function does not return the output or content of the script you're including. See http://php.net/manual/en/function.include.php for more info (example #4 might be interesting for you).

You need to get the entire content of the page, or the part(s) you'd like to e-mail, into a variable. One way of doing this is using PHP's output buffering. A good explanation of how output buffering works can be found here: http://www.codewalkers.com/c/a/Miscellaneous/PHP-Output-Buffering/

0

精彩评论

暂无评论...
验证码 换一张
取 消