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
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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.