Akshay123 Posted April 9, 2010 Share Posted April 9, 2010 Hi I have some php code like below <?php include('assets/UserAgentCheck/mobile_device_detect.php'); $mobile = mobile_device_detect(true,true,true,true,true,true,false,false); if($mobile==true){ include('/m/index.html'); }else{ include('d.html'); } end; ?> this is basically a mobile device detect script, and this code is in the file /index.php on my server it works fine, but I need some help so suppose a person is using the mobile version, and wants to switch over to the full version I know I can't use http://localhost?false , but what kind of querystrings can I use To help me, please use pretty easy steps, because i am a complete newb to php Thanks in Advance Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted April 9, 2010 Share Posted April 9, 2010 localhost/?full=1 Something like that? Then use if($_GET['full'] == 1) { //full version code here }else{ //mobile detect here } Quote Link to comment Share on other sites More sharing options...
the182guy Posted April 9, 2010 Share Posted April 9, 2010 You can use the querystring to achieve that like this: <?php include('assets/UserAgentCheck/mobile_device_detect.php'); $mobile = mobile_device_detect(true,true,true,true,true,true,false,false); $override = isset($_GET['overridemobile']) && $_GET['overridemobile'] == '1' ? true : false; // if the user is a mobile browser and they don't want the full version then include the mobile homepage, else include the full version if($mobile==true && $override == false){ include('/m/index.html'); }else{ include('d.html'); } ?> For that to work you'll need to use a link like this http://mysite.com/?overridemobile=1 I recommend using the session or a cookie to store the override value, this way you won't need to keep putting overridemobile=1 in all of your URLs. Quote Link to comment Share on other sites More sharing options...
JAY6390 Posted April 9, 2010 Share Posted April 9, 2010 I suppose you could also just have a script called something like override.php that would set the session variable and redirect back to the page you were referred from if you clicked a link on a page to override it, and show subsequent pages overriden Quote Link to comment 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.