Page 1 of 1

Filename and variables

Posted: Tue Feb 18, 2003 8:34 am
by Tubby
Hi,
Is there a way to grab certain parts from an URL and echo them into a form.
i.e. the url is
http://www.domain.tld/dir/main.php?page=24&id=42
and i want it to echo the `main?page=24&id=42` part into a form feild
$PHP_SELF returns /dir/main.php which is no good to me because i also want the variables but not the directory name.

I would hard code it as:
main.php?page=$page_no&id=$id
but the filename isnt always main.php and the variables are not always page and id.

Any help would be appriciated.
:)

Posted: Tue Feb 18, 2003 8:37 am
by daven
$_SERVER['QUERY_STRING'] for the query string and I think that $_SERVER['SCRIPT_NAME'] will get the name of the file you are in (but I am not positive, as I have never used it)

Posted: Tue Feb 18, 2003 8:37 am
by twigletmac

Posted: Tue Feb 18, 2003 8:39 am
by twigletmac

Code: Select all

echo '<pre>';
print_r($_SERVER);
echo '</pre>';
will show you all the contents of the $_SERVER array.

Mac

Thanks for your time

Posted: Tue Feb 18, 2003 9:45 am
by Tubby
Thanks :)