Im trying to use the script from ip-2-country.com to isolate surfers from a specific country (South Africa) and redirect them to a certain page. All others stay on the page. There is something wrong with this script below as it redirects to the url in "header" no matter what. Tried testing it with friends all over the world. Any ideas please?
Note: in the original script from ip2country, $httpresult echos "South Africa" so i assume it using it as an argument is the way to do it?? (yes im a newbie😃)
<?php
$ip = $REMOTE_ADDR;
$doc = "/get-country/?ip=" . $ip . "&user=guest&pass=guest";
$url = "ip-to-country.com";
$fp = fsockopen ($url, 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br/>\n";
} else {
fputs ($fp, "GET $doc HTTP/1.0\r\nHost: " . $url. "\r\n\r\n");
while (!feof($fp)) {
$httpresult = fgets ($fp,1024);
}
fclose ($fp);
}
if ($httpresult = "South Africa"){
Header ("Location: http://www.site.com/sa_page.html");
}
?>
<html>
<head>
<title>Not the SA page</title>
<meta http-equiv="Content-Type" content="text/html;">
</head>
<body>
<b>You werent in South africa so u stayed on this page</b>
</body>
</html>