1 Replies - 1120 Views - Last Post: 02 April 2013 - 01:22 PM Rate Topic: -----

#1 dazzyuk   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 28-March 13

Redirect page which passes dynamic parameters

Posted 28 March 2013 - 05:35 AM


I apologise if I have posted this thread in the wrong section, I think a php page is likely to be the best solution to my problem, but, I am open to suggestions.

I am using a platform which generates affiliate referral links for it's registered users to refer affiliates and receive referral commission on their future earnings.

The platform incorporates a default signup page (/mysite/signup) to which the default links are directed, but, I do not have access to any code on the default signup page.

It is my intention to, at a later date, introduce a custom signup page, but, if I allow the use of existing links produced by the platform and later introduce the custom signup page, all existing inbound links would still direct to the default signup page which I would no longer be using.

My thoughts to work around this are to introduce a redirect page which, for now, directs to the default signup page, but, when the custom page is introduced, I can just change the destination of the redirect to the custom page without affecting existing inbound links.

I am able to recode the default referral url which in the platform is generated from: /mysite/signup/{affiliate_id}.

So, my thoughts were to create a divert page called "register" and change the platform referral links to direct to it: /mysite/register/{affiliate_id}

NOTE: The referral urls will not work correctly when received at /mysite/signup if the "affiliate_id" is not passed in as "/1002", this is where my problem begins as any simple redirect page I can produce naturally returns a 404 error as the page /mysite/register/1002 does not exist (and if it did, it wouldn't help for affiliate 1005).

The referral link should direct to /mysite/register where the page identifies the appended "/1002" parameter and passes it into the redirect to /mysite/signup/1002.

Any help would be greatly appreciated.

I apologise if this is not entirely clear, I will happily supply any additional info needed.



Is This A Good Question/Topic? 0
  • +

Replies To: Redirect page which passes dynamic parameters

#2 huzi8t9   User is offline

  • D.I.C Regular
  • member icon

Reputation: 25
  • View blog
  • Posts: 367
  • Joined: 11-July 07

Re: Redirect page which passes dynamic parameters

Posted 02 April 2013 - 01:22 PM

Hello, dazzyuk, and welcome to Dream.In.Code.

First of all, to ensure I am understanding you properly, are you suggesting that when a user clicks a link, where the affiliate ID isn't actually in the link (for example 'my_site/sign_up') to be changed to 'my_site/sign_up/{AID}'?

If that's the case, you could set a session cookie which would expire when the session ends, but you could easily reference the cookie at any time.

Landing page
if ( !session_is_registered() ) { session_start(); }

$aid = (isset($_GET['affiliate_id']) && preg_match("/^([A-Za-z0-9]+)$/", $_GET['affiliate_id']) ? $_GET['affiliate_id'] : false);

if ( $aid ) {
    $_SESSION['AID'] = $aid;
    // OR
    //setcookie("AID", $aid);

header("Location: /signup.php");

If you place that code in your landing page, the affiliate ID will be set (if it's there and matches the pattern), then redirected to any other page.

To access it, just use $_SESSION['AID'] OR $_COOKIE['AID'].

For example, on a sign-up page

if ( !session_is_registered() ) { session_start(); }

$aid = (isset($_SESSION['AID']) ? $_SESSION['AID'] : "");
//if you used the second method
$aid = (isset($_COOKIE['AID']) ? $_COOKIE['AID'] : "");

You can use that code whenever you need to reference the code.

I hope this is of some help.


This post has been edited by huzi8t9: 03 April 2013 - 09:19 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1