Reputation: 179
I am using this code in html form
<input name="button" type="button" value="Step 2" onclick="location.href='../ticket/scp/auto.php?dest=../scp/admin.php?t=staff&a=new'"/>
when i use print_r($_GET) i get
Array ( [dest] => ../scp/admin.php?t=staff [a] => new )
whereas i expect to get
Array ( [dest] => ../scp/admin.php?t=staff&a=new )
how can i fix this
Upvotes: 1
Views: 1178
Reputation: 3670
Try this:
<input name="button" type="button" value="Step 2" onclick="location.href='../ticket/scp/auto.php?dest=<? echo urlencode('../scp/admin.php?t=staff&a=new')?>'"/>
Upvotes: 0
Reputation: 1437
Simply replace the &
with %26
. That way it is the urlencoded "&" character, which will be included in the value instead of working as a separator for the passed variables.
Upvotes: 0
Reputation: 816930
You need to encode the URI which you pass as parameter, otherwise the browser cannot know know which part belongs to which URI:
onclick="location.href='../ticket/scp/auto.php?dest=' + encodeURIComponent('../scp/admin.php?t=staff&a=new')"
You can also encode the URI on the server side.
Upvotes: 2