This topic is locked

How to redirect based on device (Phone, tablet, etc.)

4/18/2021 3:01:31 PM
PHPRunner Tips and Tricks
M
Mark Kramer author

I have been chasing this dilemma for quite some time and finally found a good working solution.

In order for your program to redirect base on device, I have found a php class that works quite well. It is called Mobile_Detect.php .

Step 1: Download the latest release form git hub from the link above.

Step 2: Copy the Mobile_detect.php file to the Custom files in phprunner.

Step 3 In the event code "after successful login" insert the following code at the top of the code :

include ("Mobile_Detect.php");
$detect = new Mobile_Detect();

if ($detect->isMobile()) {
header('Location: menu.php?page=menu'); // your redirected page
exit(0);
}

It's really that simple... The download comes with other files like .json and other things but all we need with phprunner is the Mobile_detect.php