suess0r Posted January 30, 2007 Share Posted January 30, 2007 Hi,I have a Web Site and a Mobile Site, i'm trying to determine the browser and redirecting the user depending on which they choose from. I have the script working for the most part, but there are more instances that don't fall under the categories (such as i'm using IE on my mobile device so it's redirecting me to the web site.) Does anyone konw any way around this, or have a list of $_SERVER['HTTP_USER_AGENT']'s for a mobile device I can add or any suggestions for me that could help better my script to be more dependable (not only checking for PC browsers, and push everything that doesn't fall under those categories, but are actual mobile browsers?)Code Below...[quote]<?phpglobal $userBrowser;$wmllink = "http://www.mclb411.com/mpg1.php";$htmllink = "http://www.clb411.com/pg1.php";$userBrowser = $_SERVER['HTTP_USER_AGENT']; //echo $userBrowser;//Check for Mozillaif(stristr($userBrowser, 'Mozilla')) { $ub="PC";}//Check for Mozillaelseif(stristr($userBrowser, 'gecko')) { $ub="PC";}//Check for operaelseif(stristr($userBrowser, 'opera')) { $ub="PC";}//Check for omniwebelseif(stristr($userBrowser, 'omniweb')) { $ub="PC";}//Check for msieelseif(stristr($userBrowser, 'msie')) { $ub="PC";}//Check for konquerorelseif(stristr($userBrowser, 'konqueror')) { $ub="PC";}//Check for safarielseif(stristr($userBrowser, 'safari')) { $ub="PC";}//Check for netpositiveelseif(stristr($userBrowser, 'netpositive')) { $ub="PC";}//Check for lynxelseif(stristr($userBrowser, 'lynx')) { $ub="PC";}//Check for elinkselseif(stristr($userBrowser, 'elinks')) { $ub="PC";}//Check for Mozillaelseif(stristr($userBrowser, 'Mozilla')) { $ub="PC";}//Check for linkselseif(stristr($userBrowser, 'links')) { $ub="PC";}//Check for w3melseif(stristr($userBrowser, 'w3m')) { $ub="PC";}//Check for webtvelseif(stristr($userBrowser, 'webtv')) { $ub="PC";}//Check for amayaelseif(stristr($userBrowser, 'amaya')) { $ub="PC";}//Check for dilloelseif(stristr($userBrowser, 'dillo')) { $ub="PC";}//Check for ibrowseelseif(stristr($userBrowser, 'ibrowse')) { $ub="PC";}//Check for icabelseif(stristr($userBrowser, 'icab')) { $ub="PC";}//Check for crazy browserelseif(stristr($userBrowser, 'crazy browser')) { $ub="PC";}//Check for IEelseif(stristr($userBrowser, 'internet explorer')) { $ub="PC";}//If it's not any of the above browsers//Then it gotta be a WML or very unpopular browserelse{ $ub="WML"; }//Code for redirecting based upon the resultsif($ub == "PC") { header("Location: ".$htmllink); exit; } else { header("Location: ".$wmllink); exit; } ?>[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/36296-mobile-vs-web-browser-redirection/ Share on other sites More sharing options...
redbullmarky Posted January 30, 2007 Share Posted January 30, 2007 from what i remember testing this a while back, PalmPC's/Mobiles/PDA's etc create extra variables (other than the HTTP_USER_AGENT) in the $_SERVER array. if you do a print_r dump of the $_SERVER array and run the script on the mobile device, you should be able to pick out what they are. I'll post them here if i find the script I was playing with... Quote Link to comment https://forums.phpfreaks.com/topic/36296-mobile-vs-web-browser-redirection/#findComment-172604 Share on other sites More sharing options...
suess0r Posted January 30, 2007 Author Share Posted January 30, 2007 Thanks marky, ya i tried doing an echo on the actual $_SERVER['HTTP_USER_AGENT']; and it says The Request Page cannot be Displayed.... but if i take the echo off it directs to a PC page (because it is some mobile version of IE taht I guess is getting passed as msie) if you come accross any of those differences in the variables in the $SERVER array that would help a lot, thanks! Quote Link to comment https://forums.phpfreaks.com/topic/36296-mobile-vs-web-browser-redirection/#findComment-172778 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.