-2

I am trying to come up with a php if statement for my site. I have a page called "research". There is text on this page with a link which says "contact me" This link links through to my contact page. Now, I need an if statement to say that if you are on the research page and you click on the contact me link, I need some text on the contact me page to be hidden and only be visible when you are on the contact page.

Is this possible?

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
Wizard
  • 31
  • 6
  • I don't fully understand what you're asking, but I can tell you this: The things you have at your disposal are 1: the URL the person is currently on, the referrer (the URL they were last on when they clicked to get to "this" page), 3. Javascript or code to show/hide stuff at will. Note: referrer isn't guaranteed to be available as some browsers block it for security purposes. Let me know if this gives you any ideas and I can code out how they'd work. – Joe Love Sep 21 '17 at 19:35
  • You mean `$_SERVER['HTTP_REFERER']`? – Andreas Sep 21 '17 at 19:36
  • I think it is possibly a URL thing but I don't exactly know when to start. My site is www.counsellingrooms.co.uk and the research page is https://www.counsellingrooms.co.uk/research-p2 – Wizard Sep 21 '17 at 19:37
  • On the page text, it does say contact me which links to the contact page. On the contact page, there is some text on there which I don't want showing if you are coming from the research page – Wizard Sep 21 '17 at 19:39

1 Answers1

0

On your contact page, you can get what you are looking for from: $_SERVER['HTTP_REFERER']. It will tell you which page the user came from getting to the contact page.

However, you should not rely on this. Consult the following Q&A here on Stack Overflow:

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
user3720435
  • 1,421
  • 1
  • 17
  • 27