Help with php

Discussion in 'OT Technology' started by GTS4eva, Apr 17, 2005.

  1. GTS4eva

    GTS4eva New Member

    Joined:
    Feb 20, 2005
    Messages:
    272
    Likes Received:
    0
    Location:
    California
    Hey everyone,

    I need help with some PHP here. Its really simple but I'm a complete noob at it. So heres the deal: I have a user database and people have their accounts. What I need though is something to tell them their own referral link. I already have a program tracking the clicks but I need to make each user have their ref links appear.

    So I want it to go like this. Its a php file with only http://www.mysite.com/index.php?ref=Johnny123
    Johnny123 = username

    Im not sure how I can do this since it depends on when the person is logged in with which username so I can't do a direct link to the database...

    Help?

    Thanks in advance
     
  2. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    not quite sure what you're asking.. just make it part of the url
    or.. the variables to get those fields from a url is
    $_GET['ref']
     
  3. GTS4eva

    GTS4eva New Member

    Joined:
    Feb 20, 2005
    Messages:
    272
    Likes Received:
    0
    Location:
    California
    What I mean is to take a postnuke website. While the person is online to take that username and recall it on another page. to CREATE the link http://www.mysite.com/index.php?ref=Johnny123

    Hope that clarifies?
     
  4. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,914
    Likes Received:
    8
    Location:
    Los Angeles
    There are a number of different ways to do this and each method differs depending on WHAT exactly the referrer does.

    Here is a sample on how I would do it. Just add a small sniplet of code on the top of your page
    http://site.com/index.php?ref=kingtoad
    Code:
    <?php
    if($_GET['ref'] != '') {
    $sql = "SELECT Username FROM Users WHERE Username='".$_GET['ref']."'";
    $user = mysql_fetch_array(mysql_query($sql));
    if ($_GET['ref'] == $user['Username']) { // do whatever you want to do };
    }?>
    
    Hope this helps.
     
  5. teh professor

    teh professor

    Joined:
    Dec 4, 2004
    Messages:
    1,016
    Likes Received:
    0
    I threw this into one of the blocks on my postnuke site, seems to work...

    if (pnUserLoggedIn()) {
    $content .= 'http://www.mysite.com/index.php?ref=' .pnUserGetVar('uname') . '';
    }


    Those are two single quotes at the end before the semi-colon. Not sure if that can be cleaned up somehow, I'm no php expert.
     
  6. GTS4eva

    GTS4eva New Member

    Joined:
    Feb 20, 2005
    Messages:
    272
    Likes Received:
    0
    Location:
    California
    I used the last one and it worked. Thanks everyone for contributing
     

Share This Page