Jump to content

Another Header Location problem with IE


Ekibyo

Recommended Posts

so here the thing, im trying to make a redirect by ip for my website, so i found this, and with a little twitch i made it work

 

<?php
require_once('geoip.inc');

$gi = geoip_open('GeoIP.dat', GEOIP_MEMORY_CACHE);
$country = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']);
geoip_close($gi);

$my_countries = array('us', 'ca');
//Esas son las ips de USA y CANADA se pueden aplicar mas librerias segun otros paises ejemplo Fr para FRANCIA etc..
if (!in_array(strtolower($country), $my_countries))
{
header('Location: http://www.tigo.com.hn/');
//Paginas de Honduras y el Mundo menos USA y CANADA
}
else
{
ob_start();
echo "en 10 segundos sera redireccionado a la pagina internacional, desea cancelar haga , <a href='http://www.tigo.com.hn/'>click aqui";
header('Refresh: 10; URL=http://www.tigo.com.hn/seccion/recargas-internacionales') ;
ob_flush();

}
?>

 

but in some IE Browsers dont work, just dont redirect. i fix it putting and exit(); after the header and it works

but the page dont load. i am only getting the message if i wanna redirect in a blank page.  :'(

 

so what do i want

 

i want a redirect that works in every browser.

and load the page full with the message  :shrug: i dont know what am i doing wrong

 

thnx for the help  8)

 

 

Link to comment
https://forums.phpfreaks.com/topic/264056-another-header-location-problem-with-ie/
Share on other sites

Per the manual you can't send output to the browser before a header(). I don't think you can use ob_start() to get around this and don't know why you would even try.

 

So, put the echo after the header(). The header takes 10 seconds to take effect so there is plenty of time to display the output.

 

if (!in_array(strtolower($country), $my_countries))
{
    header('Location: http://www.tigo.com.hn/');
    //Paginas de Honduras y el Mundo menos USA y CANADA
}
else
{
    header('Refresh: 10; URL=http://www.tigo.com.hn/seccion/recargas-internacionales') ;
    echo "en 10 segundos sera redireccionado a la pagina internacional, desea cancelar haga , <a href='http://www.tigo.com.hn/'>click aqui</a>";
}

i dont know why... but some minutes ago wasnt working without the

ob_start(); ob_flush();

 

and now its working...

 

Well, if you had the header() and echo swapped as you did previously I would expect it to fail. The code I posted had those two lines and I would expect them to work.

 

how can i test this if its is working with all the IE browser versions.?

Um, test it with the browser versions you want to verify against? You'll would probably want to set up virtual machines with the appropriate Operating Systems and browser versions. But, in this case I would test against the oldest version you want to support and the newest version of each browser. It's not perfect, but unless you have a team of testers it makes the most sense.

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.