What is the function in PHP to check the referring page?
In PHP, you can check the referring page by accessing the $_SERVER['HTTP_REFERER'] variable. This variable contains the URL of the page that referred the current page. You can use this information to determine where the user came from and take appropriate actions based on that.
$referring_page = $_SERVER['HTTP_REFERER'];
if($referring_page){
// Do something based on the referring page
echo "You came from: " . $referring_page;
} else {
// Handle case where there is no referring page
echo "No referring page found";
}
Keywords
Related Questions
- What alternative text editor options are recommended for avoiding BOM-related issues when working with PHP scripts?
- How can sessions be used effectively in PHP to pass variables between pages?
- How does the order of operations in PHP affect the ability to access cookies immediately after setting them?