Re: $_GET String Edit
| From: | Chris Shiflett | Date: | Sun, 23 Nov 2003 03:32:31 +0000 |
| Subject: | Re: $_GET String Edit | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-170698@lists.php.net to get a copy of this message | ||
--- "Jed R. Brubaker" <jedbrubaker@hotmail.com> wrote:
> I am trying to make a page navigation menu (we have all seen them,
> "Page: 1 2 3..."), and I would like to continue doing this via the
> URL variables. Right now, each of the page numbers is a hyper link
> is set like this:
>
> "page.php?".$_SERVER["QUERY_STRING"]."&more variables here."
>
> The problem, however, is that those variables are a string. If the
> variables that the menu defines are already in the string, it
> doesn't update them, it just adds more definitions to the URL.
I had a hard time interpreting your question, but I think you're saying
that you are generating URLs like this:
/page.php?foo1=bar1&foo2=bar2&foo1=bar3&foo2=bar4
And, you're wanting to not duplicate variables in your URL, correct?
You could always keep your query string in an array or something. This
would allow you to update values in the array prior to the end of your
script. You can start this array using $_GET:
$query = $_GET;
Of course, you might want to rather filter this data on each page, so that
you don't spread tainted data more than necessary. Regardless, this will
allow you to update values in your query string. If you want to update
foo1, you don't have to care whether it's already set:
$query['foo1'] = 'newvalue';
Hope that helps.
Chris
=====
Chris Shiflett - http://shiflett.org/
PHP Security Handbook
Coming mid-2004
HTTP Developer's Handbook
http://httphandbook.org/
RAMP Training Courses
http://www.nyphp.org/ramp