How to get URL parameter and redirect after


Please I need help with how to write php code to get a URL parameter from and redirect to another page after. My URL looks something like this

The parameter I am interested in is the referrer=forum

I need this because i am trying to integrate a forum into my website which i am almost done with except for the single sign on(SSO) feature which allows the forum to use the register and login system i have already created for my website.


Show source
| url   | php   | html   | forum   | url-redirection   2017-01-06 18:01 2 Answers

Answers ( 2 )

  1. 2017-01-06 18:01

    Something like this:

    // get parameter from URL params
    $referrer = $_GET['referrer'];
    // redirect to another URL, including the referrer above
    header('Location:' . $referrer);
  2. 2017-01-06 18:01

    You can store that parameter value in variable and pass in the link or you can use Session to use that variable across the multiple page.

        $_SESSION['referrer'] = $_GET['referrer'];

    And then in second page just use it from the session

        echo $_SESSION['referrer']; // use it as per your requirement
◀ Go back