Jasper
Jasper

Reputation: 5238

Paste variables to $_GET

I have two pages. First one we open with $_POST variables in its url, the second one opens inside first via iframe. Both php files, second is for html manipulation.

Variables I got in $_POST are passed to iframe via $_GET:

echo '<iframe src="index.php&first=' . $first . '&second=' . $second . '&third=' . $third . '&iframe=true"></iframe>';

$first, $second, $third variables has text inside them with some html and new lines (\n).

The problem is, when data is passed to iframe by $_GET, all the new lines in variables disappear.

Tryed to pass variables like base64_encode($first), and then decode them by base64_decode(). It works buggy, some parts of text don't decode correctly, maybe because of bad symbols in iframe url.

Also tryed to throw all the variables into single array, serialize it and then encode by base64 - this way server gives error 500 (it also gives the same error for 404).

Please don't ask me why I did such structure of pages. It should not be changed.

What is the solution for this?

Upvotes: 0

Views: 219

Answers (4)

Dustin Graham
Dustin Graham

Reputation: 2086

Depending on your situation you could also use Javascript to access the parent frame.

You could store the data in a javascript array of the first window, then the iframe sub window could call it via parent.*

Some more details from other questions.

Upvotes: 0

Your Common Sense
Your Common Sense

Reputation: 157892

Your initial approach is wrong.

POST variable shouldn't go anywhere. After the POST request server have to order browser to reload the page. Whole page, not only iframe in it.

After that reload you may show any iframes to user.
To pass the data there, a session would be ideal solution.
However, certain solution depends on the data nature and overall purpose of all the mess.

Upvotes: -1

haltabush
haltabush

Reputation: 4528

What about an urlencode after the base64_encode?

Upvotes: 3

Zed
Zed

Reputation: 595

You could write the contents of $first,$second,$third to first.txt,second.txt,third.txt and then open the text files inside your iframe script

Upvotes: -1

Related Questions