Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2002
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't get JS to redirect properly, please help.

    Hello,

    I bought this neat script that redirects to different product sites, but the problem is that it isn't working exactly as it should. I'll be as detailed as possible and if you have any ideas how to fix it, please let me know.

    Let's assume that the name of the script is "p.cgi". The way that it works is you upload a text file named "redirects.txt" to the same directory where the p.cgi is located.

    The contents in the "redirects.txt" looks like this...

    Now, if you go to http://www.mydomain.com/p.cgi?p=1, the "p=1" should tell it to look in the text file at the number "1" and redirect to the domain after the "|" in the number 1 postion, which is http://www.mydomain.com/page1.html.

    If I go to http://www.mydomain.com/p.cgi?p=2, then it should redirect me to http://www.mydomain.com/page2.html... and so on.

    The good news is that when I go to product 1 (p=1), it takes me to the "page1.html" like it should. But the bad news is that when I specify any other products, like p=2 or p=3, even though they are on the "redirects.txt" file, it does not recognize them and simply takes me straight to the main domain page at http://www.mydomain.com... which is specified as $mainurl in the script.

    Here's parts of the script to help you see how it's written and where I think the problem lies...

    First, the script opens like this...

    Code:
    #### The file where your redirect page urls will be saved #####
    
    $redirs = "redirects.txt";
    
    #### Your main website url ####
    
    $mainurl = "http://www.mydomain.com";
    That's pretty easy to figure out. Now, the part where I think the problem lies is this one...

    Code:
    $prod = $FORM{'p'};
    
    ##############
    
    open(LIST, "<$redirs");
    @list1 = <LIST>;
    close(LIST);
    
    foreach $linea (@list1) { chop($linea); @tempa = split(/\|/,$linea);
    
    if($tempa[0] eq $prod) { $found = 1; }
    
    if($found eq "1") {     
    print $query->redirect(-url=>"$tempa[1]");
    exit;  } 
    
    else {
    print $query->redirect(-url=>"$mainurl");
    exit;
    }
    }
    Based on what I have described, can you figure out what part of this script I can fix so that it works properly.

    Keep in mind that when I enter the "p=1" in the link, it works perfectly, but if I go to the links where I enter "p=2" or "p=3", then for some reason, the script does not recognize it and reads it as if there is nothing after the "p.cgi" and simply goes to the "else {", which means it redirects to the "$mainurl" (http://www.mydomain.com).

    Any ideas and insights to fix this will be greatly appreciated.

    Sincerely,

    Jaime Ojeda
    Last edited by jimojeda; 12-19-2004 at 12:26 AM.
    Boost Your Sales!
    Amazing Affiliate Training Videos Tutorials Will Take
    Your Affiliate Marketing To The Next Level... Check It Out

  • #2
    New Coder
    Join Date
    Jul 2002
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Oops!

    Oops!

    This isn't a Javascript, isn't it? It looks more like Perl... do you know by any chance how to fix a Perl script?

    Sorry for the mis-post.

    Sincerely,

    Jaime Ojeda
    Boost Your Sales!
    Amazing Affiliate Training Videos Tutorials Will Take
    Your Affiliate Marketing To The Next Level... Check It Out


  •  

    Posting Permissions

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