如何检查PHP中的传入链接

I am writing a PHP module where I need to check if the incoming link is coming from a particular page.

I have 2 pages :

  1. Services.php : I have a href something like this
<a href="product.php">SUBSCRIBE NOW</a>
  1. Product.php : Here I check, if the incoming link is from services.php using the following code :
$ref_url = $_SERVER['HTTP_REFERER'];
$refData = parse_url($ref_url);
if (strpos($refData['path'],'services.php') !== false ) 
{
  // Subscribe_Module
}
else
{
  //Other
}

This works fine, as long as the user clicks on the

<a href="product.php">SUBSCRIBE NOW</a>

However, there is a side effect, when the user is on services.php page and then clicks on product.php on the header, it executes, the subscribe_module in the PHP. Any idea, how to fix it ?

Thanks

Simple, Nest another loop inside If :)

if (strpos($refData['path'],'services.php') !== false ) 
{
  if($_SERVER['REQUEST_URI'] == abc/services.php)
  {
     //call services function
  }
  else
  {
    // Subscribe_Module
  }

}
else
{
  //Other
}