I have the following situation. Whenever the URL of a current page of my site looks like this: http://thisismysite.net/example.php?no_redirect=true I need all the pages my users visit from there to automatically add the "?no_redirect=true" part at the very end of the URL in order to execute the query but I got no clear idea on how to do it.
For example, on example.php I have the following links to other pages within my site.
-about.php -contact.php
If you click on those, you are redirected to about.php and contact.php respectively. However, if instead of example.php we have example.php?no_redirect=true on the address bar you should be redirected to about.php?no_redirect=true and contact.php?no_redirect=true respectively.
I tried with a referrer like this:
if (strpos($_SERVER['HTTP_REFERER'],'true') == false) {
$_GET['no_redirect']="true";
}
it didnt work. Whats the best way to achieve this?
Thank you.
Solution 1: I would recommend to save the no_redirect
variable(true/false) on $_SESSION
when the user requests the example.php
page.
Than on other pages, check the $_SESSION
variable instead of the $_GET
variable.
Solution 2: You could generate a variable based on the $_GET
parameter, something like this:
$no_redirect_param = "";
if(isset($_GET['no_redirect']) && $_GET['no_redirect'] == "true"){
$no_redirect_param = "?no_redirect=true";
}
and than include this variable at the end of each link:
<a href="about.php<?php echo $no_redirect_param; ?>">About</a>