www.webdeveloper.com
Results 1 to 4 of 4

Thread: Redirect issues

  1. #1
    Join Date
    Apr 2004
    Location
    TX
    Posts
    94

    Redirect issues

    Here is what i am trying to do:

    Step One:
    A user clicks a link on my wordpress page, they will get redirected to my geo-redirect code (although i think it is not working as it only identifies if US, and nothing else anymore, but that is another problem for another day)

    The link that they click has a custom identifier ?name=XXX

    Step Two:
    Go to redirect page, re-direct page will then grab the 'name' and if user is in US will send them to google.com

    but if anywhere else in world they will get sent to another website that needs that custom identifier. and it is here where my code crashes

    check out my code on the php detect/redirect page:


    PHP Code:
    <?php
        $name 
    $_GET['name'];

    $geocode_op = @file_get_contents ("http://api.ipinfodb.com/v3/ip-country/?key=4b0967a55992ecea5b6672aff5f2bbbf41eda3fd04e98a18a9c98b6a5c5d5221&ip=$_SERVER[REMOTE_ADDR]&format=json");

    $geocode_op json_decode ($geocode_op);

    $country_code $geocode_op->countryCode;

    if (
    $country_code == 'US') {
        
    header('Location: http://www.google.com');
        exit();
    }

    else if (
    $country_code == 'UK') {
        
    header('Location: http://www.XXXX.com/link.php?name='  $name);
        exit();
    }

    else {
        
    header('Location: http://www.XXXX.com/link.php?name=?name='  $name);
        exit();
    }  
    ?>
    ANy ideas why this is crashing


    PS. Oh btw if i don;t try to capture the $name and move it to the next page, code will work...
    Last edited by Athmaus; 10-02-2013 at 10:39 AM.

  2. #2
    Join Date
    Apr 2011
    Posts
    9
    Do you get an error when it crashes? if so what does it say?

  3. #3
    Join Date
    Apr 2011
    Posts
    9
    Also if you echo the $_GET['name'] value what does it give you?

  4. #4
    Join Date
    Apr 2004
    Location
    TX
    Posts
    94
    gives me waht is in the ?name=

    i just figured out the issue

    replace

    PHP Code:
    $name 
    with

    PHP Code:
    $name 
    works now

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles