I have a PHP webpage that takes which accepts a rat开发者_运维问答her large POST array. I have a button on the page that opens a PHP popup window. Is there a convenient way to pass the entire $_POST array to the popup?
Edit: It is an entirely different page. I open it with JavaScript: window.open
The most convenient way would be to use session variables. If your POST data is really big you might hit some performance issues though, so beware.
Post receiving page:
session_start();
//...
$_SESSION['post_for_popup'] = $_POST;
Popup:
session_start();
//...
do_something($_SESSION['post_for_popup']);
try
var_export($_POST,1);
Well, you could use a $_SESSION
variable. I assume the popup is a completely separate page so there is no other viable way to transfer the variables without doing a postback. So you could do something like this:
index.php:
session_start();
$_SESSION['post'] = $_POST;
popup.php:
session_start();
$_POST = $_SESSION['post'];
Hope that helps.
You could do one of two things.
First you could assign it to a session variable and load that session variable from the popup.
Or you could do a quick script to iterate through the $_POST array and add them as request vars on the url. This may not be right for you as your $_POST is big.
You could do the second option and add it into the header as post vars using the header() command, but I'm not sure what the added value would be there.
If I was to do it I'd put it into the session. Even a HUGE post var isn't going to take up that much session memory.
精彩评论