homepage Welcome to WebmasterWorld Guest from 54.227.12.219
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Get referring page before variables added
generic




msg:4537261
 8:49 pm on Jan 18, 2013 (gmt 0)

I want to try to store the referring page so that I can access it even if I reload the current page with a new variable and I'm just stumped.

For example, if I go from catalog.php?&category=10 to catalog.php?product=25, I want to be able to go back to catalog.php?category=10 even if I add variables onto the product part (ie, catalog.php?product=25&a=like). In the latter case, when I go back, it will return me to the product listing again, not the original category listing.

Any help would be appreciated.

 

swa66




msg:4537360
 7:10 am on Jan 19, 2013 (gmt 0)

Sounds like you want to control where the back button in the browser goes to ?

That's commonly considered breaking the back button and should not be done.
I don't think you can do it on the server side of things, you can using client side scripts (javascript) AFAIK -more complex use of ajax sometimes needs to do this to keep the back button working properly.

What you can do relatively easy is to store server side for the given session what the user has been doing and keep a "state" for them, that should solve your need without changing the URLs.

generic




msg:4537379
 8:41 am on Jan 19, 2013 (gmt 0)

I'd love to see an example of how to keep and recall a specific url "state", it's been vexing me since yesterday.

The long and skinny of it is my company just launched a small retail end to our business with our entire product catalog sitting in a mysql database plugged into a public facing front end. I've built a tablet based interface, purely for people to search the catalog while in the showroom, so it's not like Joe Public is going to be using it - it literally sits on our counter in front of me and is secured away from prying eyes outside our network.

Having said that, the end user will never see the browser back/forward buttons because the tablet display is locked in full screen all the time, we got them purely for this. I tried history.go(-1), but when someone "likes" something or "adds to cart", it refreshes and adds a variable to the query string rendering a history(-1) not only useless, but downright nasty without the right checks in place. I'm not well versed in AJAX so I need a page refresh to make these functions happen.

So therein lies the crux of my issue. I need to be able to say something like:

if ( (!isset($add)) || (!isset($liked)) ) {
$referrer = HTTP_REFERER;
} else {
$referrer = $_SESSION['saved_referrer'];
}

...but I can't wrap my head around the syntax and how to make it all remember specific history items (and recall said items for that matter). Any further help or advice would be awesome. Sorry for being verbose, it's a weird issue to try to explain.

g1smd




msg:4537397
 10:25 am on Jan 19, 2013 (gmt 0)

HTTP is "stateless".

You'll need to either use a cookie to store what you want, or pass it as a parameter.

swa66




msg:4537403
 12:04 pm on Jan 19, 2013 (gmt 0)

I'd start reading up on sessions

Ref: [php.net...]

generic




msg:4537458
 3:12 pm on Jan 19, 2013 (gmt 0)

I'm not too bad with sessions, most of the site relies on them to function as is, but storing visited url's has been eluding me for some reason. Worst case scenario, I'll rewrite the url on each page and store that but I was hoping there was a simpler or more elegant solution. Thanks anyway guys.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved