0

I have a Book a Meeting Page on my website and users came to that page when they slide through all portfolio items.

Book a Meeting page is a separate page and here i need to display in some way from which portfolio item user got to this page?

Is there any way of doing this?

Ana DEV
  • 1,018
  • 2
  • 17
  • 39

1 Answers1

1

I think the http referer https://en.wikipedia.org/wiki/HTTP_referer is what you are looking for. Although i am pretty sure that a module for the same does exist in wordpress but it is simple to implement on own also in php. here is a sample code

<?php \\$url contains the url from where the user came from $url = $_SERVER['HTTP_REFERER'] ?>

georoot
  • 3,557
  • 1
  • 30
  • 59
  • How i can get some info from that previous page @georoot? – Ana DEV Mar 18 '16 at 07:07
  • Basically the request that you get will have an http referer header set by the broser. For example suppose that a user gets to you site from google . The broser while making request to your server will add another referer header. To get it you can simply parse raw headers in PHP which you can find here http://stackoverflow.com/questions/541430/how-do-i-read-any-request-header-in-php . The value of referer header would be the url that the user came from. Remember because this is set from browser so first it is untrusted but unluckily the only way that i can think of. Pretty sure GA uses this. – georoot Mar 18 '16 at 07:13
  • Yes so i got the url correctly but how i can get some info from that url like a text @georoot? – Ana DEV Mar 18 '16 at 07:18
  • Okay so from what i understand you need to fetch content at the referer url. If that's the case use curl module in PHP to make a http request to the url and get the contents and process accordingly. A personal advise is that usually people might wan't to extract information so you might have to process the XML or render DOM to get `data` rather than raw code on previous page. – georoot Mar 18 '16 at 07:20
  • Hmm i see. Could you guide me how to do what i want CURL please? – Ana DEV Mar 18 '16 at 07:36
  • Here are some examples of exactly what you want http://php.net/manual/en/curl.examples.php – georoot Mar 18 '16 at 07:39
  • @AnahitDEV also if you think i helped you please mark the answer as correct :) – georoot Mar 18 '16 at 07:41
  • Hey @georoot i have used the code from the link and it returned the all page with styles etc. How i can get something specific like some text not the whole page please? – Ana DEV Mar 18 '16 at 07:51
  • For that you will have to parse the page and render its DOM. you can have a look at http://php.net/manual/en/book.dom.php for the same. Using this you can fetch the title of the page etc. as per your needs . – georoot Mar 18 '16 at 07:53