Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Junior Member Lucian's Avatar
    Join Date
    Aug 2003
    Location
    tennessee
    Posts
    18
    Member #
    2765
    Hey everyone,

    I've gotten myself into a bind here. I'm trying to create a simple redirect script that is part of an affiliate program I'm developing for a client.

    The flow of the script is like this:

    1. Check whether or not the $id variable has been set
    if not, go to url
    2. Then check to see whether the cookie is set. If not
    go to url
    3. Then check whether or not the $id number is valid
    if not, go to url
    4. If the id is valid, fetch the affiliate's user name
    from the db, and set a cookie containing their affiliate id that
    expires in 60 days then go to url

    All of the destination url's are the same.

    Here is the script I'm trying to use but I just can't get the darn thing to work. I haven't even written the set cookie part yet, because I can't get the dumb thing to handle correctly. Could someone help me
    figure out what I'm doing wrong, please?

    <?php
    require_once("config.php");
    if(isset($id))
    { $conn = mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
    mysql_select_db($db_name, $conn);
    $query = "select * from cbqf_users where id='$id'";
    $result = mysql_query($query, $conn);
    if(mysql_num_rows($result) == 0) {
    header("Location: $url");
    } else if(mysql_num_rows($result) == 1) {
    $cbnick= mysql_result($result, 0, 'cbnick');
    echo $cbnick;
    } else if(isset($_COOKIE['cbqf_aff']))
    {
    header("Location: $url");
    exit;
    } else {
    header("Location: $url");
    exit;
    }
    }?>

    Thx everyone!

    Lucian
    Are your website promotion efforts yielding less than satisfactory results? Check out the Website Promotion Tips Blog for help!

  2.  

  3. #2
    Member Seraph's Avatar
    Join Date
    Sep 2003
    Posts
    81
    Member #
    3090
    er what is the problem? you did not state the error... that usually helps...

  4. #3
    Member
    Join Date
    Oct 2003
    Location
    california
    Posts
    32
    Member #
    3452
    also put your code with [ code ] brackets so that it's easier to read.

    Code:
    function hereismyfunction($notice)
    {
        echo "that it's easy to read";
    }

  5. #4
    Senior Member skrlin's Avatar
    Join Date
    Apr 2003
    Location
    Illinois
    Posts
    562
    Member #
    1063
    Correction, if you are posting php code then use the [ PHP ] tags.

    Using your code as an example (with added spacing for clarity):
    PHP Code:
    <?php
     
    require_once("config.php");
     if(isset(
    $id)) {
      
    $conn mysql_connect($db_host$db_user$db_pass) or die(mysql_error());
      
    mysql_select_db($db_name$conn);
      
    $query "select * from cbqf_users where id='$id'";
      
    $result mysql_query($query$conn);
      if(
    mysql_num_rows($result) == 0) {
       
    header("Location: $url");
      } else if(
    mysql_num_rows($result) == 1) {
       
    $cbnickmysql_result($result0'cbnick');
       echo 
    $cbnick;
      } else if(isset(
    $_COOKIE['cbqf_aff'])) {
       
    header("Location: $url");
       exit;
      } else {
       
    header("Location: $url");
       exit;
      }
    }
    ?>
    Also, posting of any errors you get is always a big help for troubleshooting.

    My first suggestion is (assuming you are grabbing the $id from the url) to change this line:
    PHP Code:
     if(isset($id)) { 
    to:
    PHP Code:
     if(isset($_GET['id'])) { 
    and see if it makes the errors any better or worse.
    - Brian


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:43 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com