Page 1 of 1

$_GET information that includes "&" and "=" [solved]

Posted: Thu Feb 28, 2008 9:18 pm
by the9ulaire
I want to put the information of a url in a link. I have successfully done so. But, I want to be able to retrieve all of the information. I have put the information in the url as: back=/mypage.php?p=1&a=34&s=a

How do I retrieve that entire value? It only retrieves /mypage.php?p=1 and leaves off the rest of the information.

Am I making sense?

My problem is to make a "Back" link with information from the URL.

Thanks guys!!
LWR

Re: $_GET information that includes "&" and "="

Posted: Thu Feb 28, 2008 10:02 pm
by hawkenterprises
What I would suggest is using urlencode on your data, that will change the & and = to something useful. You can then just use urldecode and wala. Another way you might be able to get access directly is using $_SERVER['QUERY_STRING'];

Re: $_GET information that includes "&" and "="

Posted: Fri Feb 29, 2008 1:42 am
by Kieran Huggins
not sure exactly what you're looking for.... but take a look at http://php.net/http-build-query - it may be on the right track (or at least in the ballpark)

alternatively, you could explain exactly what you're actually trying to accomplish, end result wise.

Re: $_GET information that includes "&" and "="

Posted: Fri Feb 29, 2008 7:59 am
by the9ulaire
Kieran Huggins wrote:alternatively, you could explain exactly what you're actually trying to accomplish, end result wise.
Yes, yes, my apologies. I should have done that in the first place.

Okay, so on "page1.php?s=1&pn=52", you can click a link to view more detailed information on "page2.php?s=1&a=46". The link you click on on page1.php retrieves the url and enters it into the link href. The final link looks like:

Code: Select all

<a href="page2.php?s=1&a=46&back=/page1.php?s=1&pn=52">View Details</a>
So one you click the link and go to "page2.php?s=1&a=46&back=/page1.php?s=1&pn=52" I want another link to be generated which would look like:

Code: Select all

<a href="/page1.php?s=1&pn=52">Back</a>
Getting it's information from the url.

Does that better explain what I'm trying to do?

I have my first link built. It's a matter of building the "Back" link that's my problem.

Re: $_GET information that includes "&" and "="

Posted: Fri Feb 29, 2008 8:24 am
by kryles
if you are sending them back to the exact same page they came from why not try

Code: Select all

 
echo ' <a href="'.$_SERVER['HTTP_REFERER'].'">Back</a>;
 

Re: $_GET information that includes "&" and "="

Posted: Fri Feb 29, 2008 8:57 am
by the9ulaire
kryles wrote:if you are sending them back to the exact same page they came from why not try

Code: Select all

 
echo ' <a href="'.$_SERVER['HTTP_REFERER'].'">Back</a>;
 
 
I need to store that URL somehow. Because, they users can comment on the page. Which after commenting, the $_SERVER['HTTP_REFERER'] will be the page2.php they were just on, instead of going back to page1.php. Make sense? They can do stuff on page2.php, and I want the back link to be to the page that got them to page2.php from page1.php. But page1.php can have lots of different add ons to the URL.

Re: $_GET information that includes "&" and "="

Posted: Fri Feb 29, 2008 9:18 am
by the9ulaire
hawkenterprises wrote:What I would suggest is using urlencode on your data, that will change the & and = to something useful. You can then just use urldecode and wala. Another way you might be able to get access directly is using $_SERVER['QUERY_STRING'];
I actually ended up being able to do it through this. I finally figured out a way to make it work. And it works perfectly!

Re: $_GET information that includes "&" and "="

Posted: Fri Feb 29, 2008 11:53 am
by Jonah Bron
Don't forget [SOLVED] :wink: