Hello hello. What I'm trying to do is show or hide div layers based upon the previous URL. I have a user panel for a library database project for school that lists all the books a user has out as well as fines, user info etc. When I go to checkout a book I have it set up so that you enter the user account number first and are directed to the user panel which gives you the option to check out books to the user. However; I want the librarian to be able to bring up the user account information alone as well when I click on view cardholder account and I want the checkout option hidden from there.

Basically I have two url's pointing to the same page and based upon which page you come from (checkout.html or viewcardholder.html) I want the userpanel.php to hide certain div layers. I'm not sure how I'd go about this.

Member Avatar for diafol

you can use either a querystring (page.php?action=checkout OR page.php?action=view) or use $_SERVER('HTTP_REFERER') to see where they came from or use a cookie or a session cookie that stores the name of the page when opened.

Hiding is simple: just get php (or js) to change the name of the class of a div which can appear different via CSS.

However, you may just want to not have bits loaded at all. Again that's easy with php:

if($lastpage == 'checkout'){

}else{

}

use a session, its already been established to confirm the login of the librarian,, it has hasnt it? (well it should be)
get is visible in the url,
http_referer can be spoofed by the user,
both are not secure, for an item that is going to be billed to somebody(and disputed) if lost

Member Avatar for diafol

Agree, if this is an open system, avoid using querystring, $_SERVER. Session vars are the easiest method.

Who exactly is going to use this? Just the librarian or will any member of the library be able to gain entry to it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.