I am trying to detect which platform the user is using with this script at the very top of my index.php page, however it doesn't redirect when visit the page on my computer browser (it should redirect to google.com)
<?php
//Detect special conditions devices
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android");
$webOS = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");
//do something with this information
if( $iPod || $iPhone ){
header("Location: http://example.com/myOtherPage.php");
}else if($iPad){
//browser reported as an iPad -- do something here
}else if($Android){
header("Location: http://example.com/myOtherPage.php");
}else if($webOS){
header("Location: http://google.com");
}
?>
Thanks
I would bet it's because that script isn't pulling your user agent. Add an else
at the end of that conditional. Because it's not falling into any of the categories it's not being redirected
<?php
if( $iPod || $iPhone ){
header("Location: http://example.com/myOtherPage.php");
}else if($iPad){
//browser reported as an iPad -- do something here
}else if($Android){
header("Location: http://example.com/myOtherPage.php");
}else if($webOS){
header("Location: http://google.com");
}else{
echo 'User agent not detected';
}