Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Me Experts
12-28-2016, 06:26 PM
Post: #1
Help Me Experts
I want to show index.php page to mobile users and indexpc.php to pc users. How can i do that?

Please Help Me...Huh
Find all posts by this user
Like Post Quote this message in a reply
12-28-2016, 09:06 PM (This post was last modified: 12-28-2016 09:08 PM by Master_tunzwap.)
Post: #2
RE: Help Me Experts
use javascript or htcaccess

Now, the mobile website is ready and customized, but the mobile users aren’t automatically redirected to the mobile version of the website. To solve this problem, we use a PHP MobileDetect class, which can detect whether a user is using a phone, a tablet or a desktop device to access a website. You can download this PHP class from here:
https://code.google.com/p/php-mobile-detect/ . Include the class in all PHP files and add the following code:
Code:
<?php require_once 'include/Mobile_Detect.php'; $detect = new Mobile_Detect;
$device_type = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
$script_version = $detect->getScriptVersion(); $desktop = $_GET['desktop']; // If “Go to full website” link is clicked, redirect mobile user to main website
if($desktop == 1) {
                $_SESSION['desktop'] = 1;
                header("Location:" . http://www.yourdomain.com);
} // User is using a mobile phone, redirect him to mobile version of the website
if($device_type == 'phone' && $desktop != 1 && $_SESSION['desktop'] != 1) {
                $url = current_url();
                $mobile_url = str_replace('http://www','http://m',$url);                // Redirect only if no form data submitted
                if (empty($_POST)) {
                                header("Location:".$mobile_url);
                }
} ?>
Where the current_url function is:
Code:
<?php function current_url()  {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
  $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
  $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
} ?>
Find all posts by this user
Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)