Create html document on the fly

I am trying to display html text on new page on the fly. It is being displayed right now within a frame, but I create a new page if the user wants to print the document. It will not have any frames. The html code and text is placed in a string variable. The new page has the beginning and ending html code. I am trying to use PHP to put in the text in the middle. Do I use $_Post or $_Get? Or something else?

Are you using a form? If you are then you can use the $_POST, which in my opinion is the best thing to do. If you are not using a form, try using the $_SESSION variable. Put session_start() on the top of all pages before you display any headers.

As the previous post states, if you are using a form to submit the data, you will want to use the $_POST[’’] function. If you are going to be using the URL to store the data, for example: (http://www.mysite.com/index.php?variable=information)

You would then use the $_GET[’’] function. Example:

[php]
$info = $_GET[‘variable’]
echo $info;
[/php]

would output: information

Finally if neither is an option you should look into $_SESSION[’’]

Hope that helps clear things up.
For more information on any of the previously mentioned functions - http://www.php.net This is a great referance tool.

It is also possible to submit form values through GET though :wink:). You can find excellent information about these right here.

Given what I have read in this topic, I don’t believe the GET method would be very good for you.

If you are trying to pass the contents of a page (or a section of it) to a “Printer friendly” page, then the potential to have a URL too long is possible.

According to Microsoft http://support.microsoft.com/kb/208427 The url length is limited to 2083 characters. Granted this is a lot, but if you loose sight of this it could pose a problem in the future. Leave the GET method alone for something like this in favor of a POST or probably the more preferable is the SESSION.

Just my 2 cents on this one.

Sponsor our Newsletter | Privacy Policy | Terms of Service