#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    4
    Rep Power
    0
    Does anyone know of any code snippets for an affiliate type system. Whereby it tracks referals through the session_id until a purchase is made, flagging that purchase with the introducing affiliates code.
    Thanx
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    England, UK
    Posts
    83
    Rep Power
    15
    I'm trying to do this aswell, here's what I've got so far:

    Affiliate partner links to http://www.musicgoeson.com/affiliates/set_partner.php?PID=1234&target=/ - this means that their partner id (PID) is 1234 and they want the user to go to / - on set_partner.php is the following code:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <?

    mysql_connect ("localhost", "****", "****");
    mysql_select_db (****);

    session_start();
    session_name("SID");
    $session_id = session_id();

    $result_session = mysql_query("SELECT * FROM sessions WHERE id = '$session_id'");

    if ($row_session = mysql_fetch_array($result_session))
    {
    session_register("PID");
    mysql_query ("UPDATE sessions set ref = '$PID' WHERE id = '$session_id'");
    mysql_query ("UPDATE affiliates set clicks = clicks +1 WHERE id = '$PID'");
    $session_id = session_id();
    header("Location: <A HREF="http://www.musicgoeson.com$target?name=$session_id");" TARGET=_blank>http://www.musicgoeson.com$target?name=$session_id");</A>
    }
    else
    {
    session_register("PID");
    mysql_query ("INSERT INTO sessions (id, ref) VALUES ('$session_id', '$PID')");
    mysql_query ("UPDATE affiliates set clicks = clicks +1 WHERE id = '$PID'");
    header("Location: <A HREF="http://www.musicgoeson.com$target");" TARGET=_blank>http://www.musicgoeson.com$target");</A>
    }

    ?>
    [/code]

    The only problem so far is that I cannot get the header("Location... to carry on the session.


    Anyway, on every page I need to carry on the session, when they go to a page where they can buy I just call the partner ID ($PID).

    This doesn't fully work but I think the idea is right. Can anyone help?

    Girish Gupta
    webmaster@musicgoeson.com
    MusicGoesOn.com

    [This message has been edited by girish_gupta (edited September 10, 2000).]
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    73
    Rep Power
    15
    Yes, the idea is right, however, for every affiliate that signed up for your program, you've already had their info in the db, don't need to INSERT, at least to my personal experience!

    Well, it doesn't matter
    Yeah, PHP4 is much better in session management.
    If you host enable '--enable-trans-sid' , you don't even need to pass the id every time

    ------------------
    http://new.123finder.com/ - Helps you find cool domains for FREE & Registers it for only $14.95/yr
    http://www.guideclick.com/ - Qualified webmaster resources (affiliate programs, web design, tips)

    ------
    Son

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 10:45 PM
  2. How to see the Memory used by a PHP script?
    By Pardall in forum PHP Development
    Replies: 4
    Last Post: February 13th, 2004, 03:54 PM
  3. PHP with UnixODBC
    By coder4hire in forum PHP Development
    Replies: 2
    Last Post: January 20th, 2004, 01:14 PM
  4. Passing string from PHP to Javascript
    By ka8oad in forum JavaScript Development
    Replies: 4
    Last Post: January 17th, 2004, 03:12 PM
  5. UnixODBC + PHP + Apache + Empress
    By coder4hire in forum Database Management
    Replies: 0
    Last Post: January 15th, 2004, 01:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo