Store Source of Page as Variable

So I'm working on a shirt printing quoter for a client. Basically you fill out a few fields and it tells you how much it would cost to print your design on 24+ shirts. After you see your total, you can place your order by filling in contact info and submitting the order. This is supposed to send an email to the company with your order details, as well as to you as a sort of receipt.

I would like to make my life a lot simpler by just storing the source of a page I already generated, as a variable, and then using that as the message body. Does anyone know if there is a way to do this? The page is dynamically generated, so it's not just a static page I can link to.

You could use ob_start() , include the file that creates the page (taking care to add any necessary GET variables to the include path as you would with a URL), and then store the contents of ob_get_contents() in a variable. Demo below:

index.php

//Start output buffering
ob_start();
//Get the contents of the dynamic page
require('dynamic.php?a=10');
//Get the contents of the page through the OB
$contents = ob_get_contents();
//To demonstrate it works
echo '$contents = ';
var_dump($contents);

dynamic.php

//Sample dynamic content
echo 'This is dynamic. A = '.$_GET['a'];

If you need to send POST variables to the dynamic page you could use cURL instead. A demo of this is below.

So I'm working on a shirt printing quoter for a client. Basically you fill out a few fields and it tells you how much it would cost to print your design on 24+ shirts. After you see your total, you can place your order by filling in contact info and submitting the order. This is supposed to send an email to the company with your order details, as well as to you as a sort of receipt.

I would like to make my life a lot simpler by just storing the source of a page I already generated, as a variable, and then using that as the message body. Does anyone know if there is a way to do this? The page is dynamically generated, so it's not just a static page I can link to.

Thanks

hi there! Ϋ

would you mind displaying a part of your code that has relation with that?
that's to solve the problem faster.

i do also have an idea about on what baudday's asking for.
programmers have different ways in solving the same problem, right?

mine's to adjudicate first if possible, the summary of a whole program code,
and after doing so that's when I'll start giving it a shot. Ϋ

it's also my way on knowing how good the person is in terms of his or her coding.
and just so you know i guess you're one of the best already. Ϋ

:icon_wink: mabuhay ka PMC!

You have a valid point. Sometimes it is better to post code (as a rule, it's a good idea to post some for reference) and other times its not. Though, as the asker, its nicer if answers can be tailored to their exact needs. Salamat ﻼim!

baudday: If this thread has been solved, please make sure to mark it as solved so other users know that this thread does not need further clarification. Thanks! :D

You have a valid point. Sometimes it is better to post code (as a rule, it's a good idea to post some for reference) and other times its not. Though, as the asker, its nicer if answers can be tailored to their exact needs. Salamat ﻼim!

baudday: If this thread has been solved, please make sure to mark it as solved so other users know that this thread does not need further clarification. Thanks! :D

this just proves that i still have a lot to learn! :$
i haven't used any of the functions here.
really nice to know all this.

this just proves that i still have a lot to learn! :$
i haven't used any of the functions here.
really nice to know all this.

thanks PMC. Ϋ

You're welcome! :D

As you learn more about PHP, you'll see a lot of these useful features like cURL. As it says in my signature, be sure to take some time to look over some of the listed extensions on the PHP.net documentation. You'll discover some other great extensions such as the GD image library. Best of luck with your future PHP scripts!
-PMC

As you learn more about PHP, you'll see a lot of these useful features like cURL. As it says in my signature, be sure to take some time to look over some of the listed extensions on the PHP.net documentation. You'll discover some other great extensions such as the GD image library. Best of luck with your future PHP scripts!
-PMC