Page 1 of 1

Getting the value of the address bar

Posted: Mon Aug 02, 2004 9:42 pm
by evilmonkey
Hello. Can someone please tellme how I can get the value of the adress bar? I have a script that does something to the effect of:

Code: Select all

script.php?var1=value1&var2=value2&var3-value3..
for about 6 or 7 values. $_SERVER['PHP_SELF'] returns only script.php, I need the value of the whole bar. How can I find it? Thanks!

Posted: Mon Aug 02, 2004 9:44 pm
by xjake88x
Use javascript.. location.href

Posted: Mon Aug 02, 2004 9:45 pm
by evilmonkey
Thanks Jake!

Posted: Mon Aug 02, 2004 11:31 pm
by kettle_drum
Or in php:

Code: Select all

$_SERVER['QUERY_STRING'];
$_SERVER['REDIRECT_QUERY_STRING'];
Or you can just do a foreach on $_POST.

Posted: Tue Aug 03, 2004 11:10 am
by evilmonkey
Actually, I decided to do this:

Code: Select all

<?php
//after I converted the variables from $_POST
$url = $_SERVER['PHP_SELF']."?var1=$var1&var2=$var2"//...etc
?>
Also, kettle_drum, that would be a foreach on $_GET ;)

Posted: Tue Aug 03, 2004 1:58 pm
by burzvingion
kettle_drum wrote:Or in php:

Code: Select all

$_SERVER['QUERY_STRING'];
$_SERVER['REDIRECT_QUERY_STRING'];
Or you can just do a foreach on $_POST.
$_SERVER indexes vary by system/server. if you want the whole absolute url:

Code: Select all

$url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']
// or if you're sure theres going to be GET data:
$url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
All those $_SERVER vars are available with apache