We help IT Professionals succeed at work.

PHP Request Variables

Phatzer
Phatzer asked
on
7,868 Views
Last Modified: 2008-01-09
Hey,

I've been using PHP for a few years properly now and there's one thing that's bugged me for a while and I need somebody to give me a hand.

Now, let's say I have a link like this: page.php?1=value1&2=value2

When I add a hyperlink to a page to change 2's value I'd do this: <a href="page.php?2=newvalue">Link</a>

Problem is, 1's value is now lost. So, I created a small script to output the request variables in the address to a string to use in my hyperlinks like this: <a href="page.php<?php echo $urlrequest ?>2=newvalue"></a>

The problem this time is that it will not change the current value of 2, it will just add it to the end like this:
page.php?1=value2&2=value2&2=newvalue.

What is the best way to overcome this issue so that I can change current request variables and possibly even remove specific request variables?

Cheers,
Dan.
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2006
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Joe WuDeveloper | Solutions Architect | CTO
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Not tested the solutions yet, but I'm sure that it will be good enough for what I need to know. Using sessions for the info is a pretty good idea actually, in the past, I've only ever used sessions to handle logging in and basic user info.

I'll split points evenly, thanks for the help, I'm sure I'll get round to using the idea soon :)

@nizsmo: The semi-colon thing I know that it wasn't added, I just typed it all here, it's not a final piece of code just an idea that's all.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.