Re: Pass vars in URL
| From: | Monty | Date: | Mon, 14 Oct 2002 20:17:28 +0000 |
| Subject: | Re: Pass vars in URL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-119946@lists.php.net to get a copy of this message | ||
There are two ways to do this. The easy way is to simply load any vars
passed via the URL or from a form as local vars in each script. So, I have
the following at the beginning of every script:
extract($_GET); // load vars passed via URL into local vars.
extract($_POST); // load vars passed via Forms into local vars.
If I pass ...?param=1 via the URL, then the extract($_GET) function will
automatically create a local var of the same name: $param
Or, you can access each variable directly. Say you pass the following via
the url:
www.site.com/page.html?param=1
In your script you can access the "param" var this way:
$_GET('param')
It's a pain to rejig all your scripts to work this new way, but, the
security benefits are worth it. Have a look here for more details...
http://www.php.net/manual/en/language.variables.predefined.php
http://www.php.net/manual/en/function.extract.php
Monty
> From: garyb10@earthlink.net (Gary)
> Newsgroups: php.general
> Date: Mon, 14 Oct 2002 15:07:21 -0400
> To: php-general@lists.php.net
> Subject: Pass vars in URL
>
> Hello,
> My host has upgraded to 4.2 but still uses the old ini setting. I am
> trying to rewrite my scripts so when the day comes for my host to make
> the change I will be ready. Everything has been going well till now. I
> have been passing an id through a url string. Now when I try to pass the
> id it show up in the url but does nothing. If i check if it is
> set, it is not. IT is supposed to pass the id number to mysql on the
> linked page. I there something I am missing some new way or do I need to
> turn on something in the ini?
>
> TIA
> gary
>