I would like a "Back to search results" link to be displayed on a page only if the user accessed that page from the search results page (search.php). If the user accessed the page directly i.e by typing URL directly in to browser, the link does not get displayed.
You could use HTTP_REFERER if(strstr($_SERVER['HTTP_REFERER'], "search.php")) { echo ("Back to..."); } PHP: