No redirecciona correctamente en un if
| From: | Fernando Seves | Date: | Mon, 04 Feb 2008 11:21:12 +0000 |
| Subject: | No redirecciona correctamente en un if | ||
| Groups: | php.general.es | ||
| Request: | Send a blank email to general-es+get-62222@lists.php.net to get a copy of this message | ||
Hola
Tengo el siguiente programilla que redirecciona a distintas paginas si se
navega en Windows y no se tiene IE o si se navega y Mac y no se tiene
Firefox ademas de discriminar IP que empiezan por 202.
Creo que la logica está bien pero me da este error:
Warning: Cannot modify header information - headers already sent... y no
redirecciona ¿Que puede estar pasando?
un saludo cordial y muchas gracias
<h3>Welcome to Acme Software</h3><p>
This software only works with Mac/Firefox or Win/IE. If you don't have one
of those combinations will be redirected to a proper page.<p>
<?php
$client = $_SERVER['HTTP_USER_AGENT'];
$ip = $_SERVER['REMOTE_ADDR'];
if (!eregi("MSIE", $client) && eregi("Windows", $client)) {
$url = "
http://www.microsoft.com/windows/products/winfamily/ie/default.mspx";
header("Location: ".$url);
exit();
echo "Tienes windows pero no IE";
}
else if (!eregi("Firefox", $client) && eregi("Macintosh", $client))
{
$url = "
http://www.apple.com/downloads/macosx/internet_utilities/mozillafirefox.html
";
header("Location: ".$url);
exit();
echo "Tienes Mac pero no Firefox";
}
else if (eregi("^202", $ip)){
echo "You are not allowed to test our software... hacker.";
exit();
}
else {
echo "<h2><a href='#'>Yo can download our
software!!</a></h2><p>";
echo "<small>$client<p>$ip</small>";
}
?>