Get the page the user has viewed before the current one
HTTP_REFERER is not always set, so you get a notification. The browser can refuse to submit, or the user can enter the URL directly into their browser. You can put this value in session , which has other drawbacks (for example, multiple tabs in the browser have the same referrer page.) I think url is still the best way if you don't have a form. to which you can add a hidden field.
EDIT . By the way: don't use a URL in the get parameter blindly, which might be spoofed by others again, as explained in the answers to this other question .
source to share
HTTP_REFERER
(and almost every other $ _SERVER var) is not a reliable means of obtaining previous pages, as they can easily be faked.
Setting up a session variable might be a little more secure, but won't work if they come from an external url. Afayk is not a crazy method to achieve this.
source to share