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 Link to comment https://forums.phpfreaks.com/topic/198140-querystrings/ 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 } Link to comment https://forums.phpfreaks.com/topic/198140-querystrings/#findComment-1039612 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. Link to comment https://forums.phpfreaks.com/topic/198140-querystrings/#findComment-1039613 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 Link to comment https://forums.phpfreaks.com/topic/198140-querystrings/#findComment-1039618 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.