PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
evilmonkey
Forum Regular
Posts: 823 Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada
Post
by evilmonkey » Mon Aug 02, 2004 9:42 pm
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!
xjake88x
Forum Commoner
Posts: 50 Joined: Sun Aug 01, 2004 7:05 pm
Post
by xjake88x » Mon Aug 02, 2004 9:44 pm
Use javascript.. location.href
evilmonkey
Forum Regular
Posts: 823 Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada
Post
by evilmonkey » Mon Aug 02, 2004 9:45 pm
Thanks Jake!
kettle_drum
DevNet Resident
Posts: 1150 Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England
Post
by kettle_drum » Mon Aug 02, 2004 11:31 pm
Or in php:
Code: Select all
$_SERVER['QUERY_STRING'];
$_SERVER['REDIRECT_QUERY_STRING'];
Or you can just do a foreach on $_POST.
evilmonkey
Forum Regular
Posts: 823 Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada
Post
by evilmonkey » Tue Aug 03, 2004 11:10 am
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
burzvingion
Forum Newbie
Posts: 11 Joined: Sun Apr 18, 2004 2:30 pm
Post
by burzvingion » Tue Aug 03, 2004 1:58 pm
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