Solved

How do I fix a php mobile detect and redirect script to allow users on mobile devices to see the full site

Posted on 2016-09-27
4
175 Views
Last Modified: 2016-11-05
I have this script at the top of my code:

<?php
error_reporting(E_ALL ^ E_NOTICE);
 session_start();
$refering_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
//echo $refering_url;
if (strpos($refering_url,'mobile/ab-moving-storage-mobile.html') !== false) {
    //echo 'true';
	$_SESSION['last_url']=$refering_url;
}
else
{
//echo "else condition...";
if($_SESSION['last_url']=="") {
 require_once('mobile_device_detect.php');
mobile_device_detect(true,true,true,true,true,true,true,'http://www.abmoving.com/mobile/ab-moving-storage-mobile.html',false);
}
//$_SESSION['last_url']="";
}

?>

Open in new window


It redirects with no problem, but when "Go to Full Site" is clicked from the mobile version of the page, it will not display the full site version on the mobile device. It redirect to the mobile version

The desktop page: abmoving.com/ab-moving-storage.php
The mobile page: abmoving.com/mobile/abmoving-storage-mobile.html

We are working on a responsive site but I need this in the meantime.
0
Comment
Question by:weknowjack
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 400 total points
ID: 41819640
you must add a parameter in the "Go to Full Site" link/button.

so you can check if it was a click from it :

$gotoFullSiteClicked = $_GET["gotofull"] == "1"; // check if the parameter gotofull is set to 1

else if($gotoFullSiteClicked)
{
   // go to full site

Open in new window

0
 

Author Comment

by:weknowjack
ID: 41819668
Thank you, but I am not a coder. Where would this parameter be placed? In the non-mobile page?
0
 
LVL 110

Assisted Solution

by:Ray Paseur
Ray Paseur earned 100 total points
ID: 41826559
Been out of town for a few weeks and returned today.  Got a neglected question alert on this one.  Here is my take on the question.

The trend from desktop to mobile "tipped" in 2012.  Nobody uses mobile detection any more.  The assumption today (2016) is that all accesses are coming from mobile first.  This means that we design for mobile, and let desktop be the graceful fallback.  To that end, tools like Twitter Bootstrap are the right way to go.  The interim step of trying to shoehorn an old desktop site into some kind of mobile-friendly structure may not be value-added.  In my experience, it's faster and gets better results, if you just refactor the old site (only once).

Also, you really need a coder to handle this.  It's worth the investment to get it completely right, and the results will likely serve you well for a long time!
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question