Programming, website development forum Get latest updates by RSS Follow TechnicalTalk on Twitter Follow TechnicalTalk on Facebook 
HomeSearchRecent PostsLoginRegisterContact Us

Username  
Password    
  Forgot your password?  

Pages: [1]   Go Down
 
  Email this topic  |  Print
0 Members and 1 Guest are viewing this topic.

PC/mobile redirect

 
webmaster forum
Activity
0%
 
New Coder
Posts: 26
Topics: 12
January 21, 2009, 07:44:09 PM

heres a php code for those who need a PC/Mobile redirect...

Code:
<?php

global $userBrowser;

// Your wapsite

$wmllink "http://www.yoursite.com/";

// Your website

$htmllink "http://www.yoursite.com/";


//Detect the browser
$userBrowser $_SERVER['HTTP_USER_AGENT']; 


//echo $userBrowser;

if(strpos(strtoupper($HTTP_ACCEPT),"VND.WAP.XHTML+XML") > 0)
{
  
$ub="PC";
}
else if(
strpos(strtoupper($HTTP_ACCEPT),"XHTML+XML") > 0)
{
  
$ub="PC";
}
//Check for Mozilla
else if(stristr($userBrowser'Mozilla')) 
{
  
$ub="PC";
}
//Check for msie
else if(stristr($userBrowser'msie')) 
{
  
$ub="PC";
}
//Check for IE
else if(stristr($userBrowser'internet explorer')) 
{
  
$ub="PC";
}
//Check for opera
else if(stristr($userBrowser'opera')) 
{
  
$ub="pc";
}
//Check for Opera
else if(stristr($userBrowser'Opera')) 
{
  
$ub="pc";
}
else
{
  
$ub="WML";
  }
if(
$ub == "PC") {
    
header("Location: ".$htmllink);
    exit;
    }
    else 
    {
    
header("Location: ".$wmllink);
    exit;
    }

?>

 
webmaster forum
polas  Offline
Activity
33.33%
 
Code Guru
Gender: Male
Posts: 1399
Topics: 85
WWW
January 22, 2009, 03:28:00 AM

Thanks for posting that
Is there not a string for phones which would cut that all down?

Instead of all those conditional branches I would combine them where I could with logical OR - would cut the code down

Mesham Type Oriented Parallel Programming Language, Free online technical support
 
  Email this topic  |  Print
Pages: [1]   Go Up
 
Jump to:  



Powered by SMF 1.1.15 | SMF © 2011, Simple Machines


Google visited last this page February 07, 2012, 04:05:10 PM