what i need is: create a redirect page with diffrent content (in same url) depending on source url where visitor come! for exemple :
- Visitor X come from a href url www.example.com/page?u=target1.com
- Visitor Y come from ahref url www.example.com/page?u=target2.com
the redirect page for both visitors X and Y is www.example.com/redirect-page but with different content for the visitor X a (button) with a href button to target1.com for the visitor Y a href (button) to target2.com (sorry for my bad english, i hope get the right answer )
CodePudding user response:
- read the query parameter
parse_str($_SERVER['QUERY_STRING'], $queries); $queries["u"] will be the target
- Store the target value in session
$_SESSION["targetValue"] = $queries["u"]
- Redirect the user to /redirect-page/
- You can show/hide/render depending on
$_SESSION["targetValue"]
CodePudding user response:
By "redirect-page", if you mean it is actually redirecting to another 3rd page, then @ruleboy21's comment is correct.
But I think you mean "redirect-page" is the page that people are being redirected to, and you just want to add a customized "back" button to it. If so, here is one approach:
if ( !empty($_GET['u'] ) {
echo '<a href="'.htmlspecialchars($_GET['u'], ENT_QUOTES,'UTF-8').'" style="border:1px solid black;padding:2px;"> back </a>';
}
Which doesn't create a <button>
, but rather an <a>
link containing the referring page in it's href attribute, and has some styling to make it look like a button (which you can change however you want).