Skip to content
Advertisement

PHP/HTML: Mobile website to desktop website using mobile device

I’ve expanded my website by adding a ‘mobile device detector’ to it, so that is will send you to a different page when you’re using a mobile device (check it out here, and for the mobile version here (of course it will automatically send you there when using a mobile device if you clicked the first link. Note: If it’s not working, let me know!)

Now anyways, I ran into an issue. At the mobile website, I want to add a way to switch to the desktop version (also the other way around). I found that this couldn’t be possible without a variable to store that in, or the server would have to many redirects. Now, I can’t find a way to do that thing. I’ve already tried deploying the php $_POST[''] method and the php $_GET[''] one, but I can’t find where and how to use it.

Thanks!

EDIT: As requested, here’s the code where I detect devices:

JavaScript

Well, I must say that I didn’t make this myself, but downloaded the thing from a website.

Here’s the code on the mobile page that detects again, but this time if it’s not true:

JavaScript

Advertisement

Answer

How about if you call:

JavaScript

Then check in your page:

JavaScript

Then ensure that you tell both versions of your website (desktop and mobile) that if this $_GET param exists in the request, then ignore all useragent checks like so:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement