Forum Moderators: coopster

Message Too Old, No Replies

GET/POST Confusion

GET & POST arrays are being manipulated somehow

         

justgowithit

1:53 am on Dec 22, 2006 (gmt 0)

10+ Year Member



I've got a script that accepts two vars via GET from a javascript link like so (I've left the link escaped):

<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.

eelixduppy

3:28 am on Dec 22, 2006 (gmt 0)



Something isn't making any sense here. I've tried this on my server:

<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?

justgowithit

3:48 am on Dec 22, 2006 (gmt 0)

10+ Year Member



'window' is not the actual function. The actual function is created via Dreamweaver behavior. That is not the issue.

I am aware that the issue is with the javascript. Thanks anyway, I'll work on it.