Jump to content

redirect help


486974

Recommended Posts

hi all,

 

i am using an Ip-to-country script which echos what country the user is from is there anyway once it comes up with the country of redirecting from that page to another e.g lets say user is from UK then they get redirected to a UK booking calendar if they are from the US they redirected to a US booking calendar

 

heres the script

 

<?php

if (getenv(HTTP_X_FORWARDED_FOR)=="") {

$ip = getenv(REMOTE_ADDR);

}

else {

$ip = getenv(HTTP_X_FORWARDED_FOR);

}

$numbers=explode (".",$ip);

$code=($numbers[0] * 16777216) + ($numbers[1] * 65536) + ($numbers[2] * 256) + ($numbers[3]);   

$lis="0";

$user = file("data.dat");

for($x=0;$x<sizeof($user);$x++) {

$temp = explode(";",$user[$x]);

$opp[$x] = "$temp[0];$temp[1];$temp[2];$temp[3];$temp[4];";

if($code >= $temp[0] && $code <= $temp[1]) {

$list[$lis] = $opp[$x];

$lis++;

}

}

if(sizeof($list) != "0") {

for ($i=0; $i<sizeof($list); $i++){

$p=explode(';', $list[$i]);

echo "You are from $p[4]";

}

}else{echo "Unable to determine your country"; }

?>

 

 

in the package is a DAT file aswell

Link to comment
https://forums.phpfreaks.com/topic/101393-redirect-help/
Share on other sites

You could use if statements, or something like this...

switch ( $p[4] )
{
case 'UK'  : ....do whatever...
             break;
case 'Canada'  : ....do whatever...
             break;
default : ...catch all for countries you haven't accounted for...
             break;
}

Link to comment
https://forums.phpfreaks.com/topic/101393-redirect-help/#findComment-519157
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.