Forum Moderators: coopster
<a href=\"javascript:;\" onClick=\"window('dir/page.php?var1=" . $row['var1'] . "&var2=" . $row['var2'] . "','','scrollbars=yes,width=700,height=500')\">Link</a>
On the receiving I call the variables with: $_GET['var1'] & $_GET['var2'] respectively and the values display exactly as they should. The problem is that I get an error showing that the GET array is empty and that the POST array is holding the values like so:
[_POST] => Array
(
[var1] => val
[var2] => val
)
[HTTP_POST_VARS] => Array
(
[var1] => val
[var2] => val
)
[_GET] => Array
(
)
[HTTP_GET_VARS] => Array
(
)
If I refer to the variables on the receiving page using $_POST['var1'] & $_POST['var2'] I get the same 'undefined index' error only the globals show the opposite issue like so:
[_POST] => Array
(
)
[HTTP_POST_VARS] => Array
(
)
[_GET] => Array
(
[var1] => val
[var2] => val
)
[HTTP_GET_VARS] => Array
(
[var1] => val
[var2] => val
)
I have no idea what's happening here. The problem seems to stem from the javascript link. If I refer to the page with an html link ( <a href="somepage.php">link</a> ) all is well and no errors are thrown. For the life of me I can't understand why the javascript link is cramping my style here.
<a onClick="open('index.php?var1=fish&var2=monkey','','scrollbars=yes,width=700,height=500')">Link</a>
It seems that your javascript isn't correct, so I've changed it a little to make it work. window is not a function.
And then index.php (the window opening) contains this:
echo '<pre>';
print_r(get_defined_vars());
echo '</pre>';
echo $_GET['var1']; //echos 'fish'
echo $_GET['var2']; //echos 'monkey'
echo $_POST['var1']; //error!
echo $_POST['var2']; //error!
Everything is working as it should be for this.
I'm thinking that javascript may be causing an error and not passing the query variables correctly?