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
102 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
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 108

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

705 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now