How to get the request page name or uri from which the source page is loaded.
Explanation below:
index.php
<?php
header('Location:target.php');
?>
target.php
<?php
// How to check here if the redirection has happened from index.php
?>
How to get the request page name or uri from which the source page is loaded.
index.php
<?php
header('Location:target.php');
?>
target.php
<?php
// How to check here if the redirection has happened from index.php
?>
you can use the code below
echo $_SERVER["HTTP_REFERER"];
but to make sure you can get really the exact origin of your page you can store the current url to a session before doing a redirection and read it to the next page.
in the origin page
$_SESSION['origin'] = $_SERVER['REQUEST_URI'];
then in next page
echo $_SESSION['origin'];
you can use $_SERVER["HTTP_REFERER"] but it can't be trusted. Some browsers will have the correct value other will have null value.
Here is what php manual says about it:
'HTTP_REFERER' The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.
In short, I don't think you can get a reliable solution for what you want.