tags:

views:

38

answers:

4

I have a script which takes in html from the user as in full page html either from the user or grabs it via curl or from an email. The thing is that I have the html in a string but on the same page I need to show the htmnl in a separate iframe. I don't want to reput any database, curl or imap code in the page referenced by teh iframe at all - is there a way for me to show html passed into a url somehow? like as in a get variable .. the html can be huge here... sorry if it sounds weird.

A: 

(if i am not misunderstanding your question)

You could put the string in a textarea inside a form and submit the form ..

the receiving page would read the posted data and render it on the page..

Gaby
A: 

I'm not quite sure what you want to do, put you could always post the string as a POST variable, no limitations on how long they can be.

Andreas Jansson
A: 

You can encode pieces of HTML with urlencode which is automatically decoded when you retrieve it with $_GET or you can use e.g. base64_encode and base64_decode. The problem is that there are limits to $_GET and $_POST. Both can be set in your configuration settings, but sending large amounts of data via the URL is really not-done because that's not how it should be used.

But if I read your question correctly, you can fetch the HTML at the top of the page, and then load it into an iframe?

if ($_GET['url']) {
  $html = file($_GET['url']);
}
if ($_POST['html']) {
  $html = $_POST['html'];
}

And then include it:

<html>
..
<iframe ..><php echo $html; ?></iframe>
..
</html>
Alec
the content of the iframe tag is not displayed unless the browser doesn't support iframes... you have to put a link into src attribute in order for the iframe to show anything. http://www.w3schools.com/TAGS/tag_iframe.asp
kgb
A: 

you can put the grabbed html into a temp file and put the link to that temp file into src="" of the iframe

kgb
I like the temp file idea - what would be an effective way to create temporary files like this?
Ali
you can create them using tempnam() (http://php.net/manual/en/function.tempnam.php). then create a small script that gets (preferably obfuscated) filename and simply prints it out if it was really a temp file created by you(be careful! if it doesn't check the filename well - you are giving full read access to your server)... put the link to this script in the src of the iframe.you can also create temp files in the public folder of your www server, but i wouldn't want temp/garbage there.
kgb