Jump to content

querystrings


Akshay123

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.