SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP - Redirect not working correctly

    Hi Guys,

    I need your help please. I'm trying to load a URL like the following:

    http://www.xxxxx.com/track/clickbeta...d=testurl&lp=1

    Now as you can see in the url i have the following:

    &lp=1

    Here is my code:

    PHP Code:

    //XXX LP - XXX UK
    if ( $lp == "1" ) {
        
    $url="xxxxxxxxxxxxxxx.com";
    };

    //XXX LP - XXX UK
    if ( $lp == "2" ) {
        
    $url="xxxxxxxxxxxxxxxxxx.com";
    };

    if (isset(
    $lp)) {
        
    //do nothing
    } else {

    mysql_connect(localhost,$username,$password);
    @
    mysql_select_db($database) or die( "Oops theres an error, our highly trained monkeys have been notified.");

    $query sprintf("SELECT URL FROM programs WHERE ID ='%s'",
                
    quote_smart($p));

    mysql_query($query) or dies(mysql_error()); 
    $result mysql_query($query);
    $url=mysql_fetch_array($resultMYSQL_ASSOC);
    mysql_close();


    };

    $string =$url['URL'];
    $string addslashes($string);
    $urlgo=eval("\$string = \"$string\";");
    header'Location: '.$string.'' ) ; 
    There is more code than the above such as connecting the the database and variable setting but i the i think with the above you can see what im trying to do. But how ever when i try the URL above with the &lp=1 it just takes me to:

    http://www.xxxxxxxxxxx.com/track/h

    and not the URL thats in the script. Can someone help me please and tell me where im going wrong?

    Thank you.
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!

  2. #2
    SitePoint Addict kduv's Avatar
    Join Date
    May 2012
    Location
    Maui, HI
    Posts
    211
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    I'm not sure why you have addslashes and eval there. What happens if you just do:
    PHP Code:
    $string $url['URL']; 
    header'Location: '.$string ); 
    exit(); 
    Keith
    Freelance web developer
    http://www.duvalltech.com/

  3. #3
    SitePoint Addict
    Join Date
    Mar 2011
    Location
    Manchester, UK
    Posts
    226
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    I was told to do that as sometimes the URL will have a variable in it for example http://www.google.com/?id=$affid

    But when loading the URL $affid wasnt being replaced with the data thats stored in that variable and was just sending people to the URL with the variable as PHP code. So i was told to do that and then it started to work.

    Any help with this guys would be much appreciated.

    Thank you!
    You're Help Does Not Go Unnoticed, I have So Far Donated 25 GBP
    To Cancer Research UK As A Thank You To All The SitePoint
    Members That Have Helped Me In The PHP Forum Thank You!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •