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
156 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 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