What I want to do is when user goes to one page I redirect him to another page while sending some post variables to this latter page.
+1
A:
You can't redirect a user and simultaneously send any POST data.
webdestroya
2010-05-31 04:35:53
A:
While it is true you cannot send variables into the $_POST array while redirecting you can use sessions to store the data and then redirect.
so
session_start();
$_SESSION['post_array'] = $_POST;
header("Location: next_page.php");
Then on next_page.php
session_start();
$_SESSION['post_array'] contains all the post variables from the previous page
Geek Num 88
2010-05-31 04:43:52
I want it to be invisible for the user that I send some vars. Sessions may show up in the url.
Alex Polo
2010-05-31 04:46:40
You will want to quote `post_array`.
Artefacto
2010-05-31 04:48:43
@dfjhdfjhdf you don't need to be invisible. You need to be **way** more specific when asking questions not having basic knowledge. What page, what data, what user, what's the reason to be "invisible". So, most experienced ones may phrase a real question for you.
Col. Shrapnel
2010-05-31 05:02:56
I am not going to tell the whole story. It's too long and uninteresting.
Alex Polo
2010-05-31 06:10:28
While true that you should quote `post_array` you are not required to.
Geek Num 88
2010-05-31 18:40:10
@Geek `define('post_array', 'foo')` - Woops. You *are* required to quote strings if you mean strings.
deceze
2010-06-04 05:38:00
A:
You can't do it with just PHP. It's possible with Javascript however:
<form id="f" method="post" action="http://example.com">
<input type="hidden" name="var1" value="value1" />
<input type="hidden" name="var2" value="value2" />
</form>
<script type="text/javascript">
window.onload = function () {
document.getElementById('f').submit();
}
</script>
You might want to load the values and names with PHP.
DXL
2010-05-31 18:44:16