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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
the9ulaire
Forum Commoner
Posts: 74
Joined: Mon Jun 11, 2007 11:31 am

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

Post 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
Last edited by the9ulaire on Fri Feb 29, 2008 2:57 pm, edited 1 time in total.
User avatar
hawkenterprises
Forum Commoner
Posts: 54
Joined: Thu Feb 28, 2008 9:56 pm
Location: gresham,oregon
Contact:

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

Post 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'];
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

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

Post 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.
the9ulaire
Forum Commoner
Posts: 74
Joined: Mon Jun 11, 2007 11:31 am

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

Post 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.
kryles
Forum Contributor
Posts: 114
Joined: Fri Feb 01, 2008 7:52 am

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

Post 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>;
 
the9ulaire
Forum Commoner
Posts: 74
Joined: Mon Jun 11, 2007 11:31 am

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

Post 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.
the9ulaire
Forum Commoner
Posts: 74
Joined: Mon Jun 11, 2007 11:31 am

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

Post 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!
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

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

Post by Jonah Bron »

Don't forget [SOLVED] :wink:
Post Reply