I usually post code but this is a slightly different case.
I would like to disable my registration page from being used on a mobile device.
EG: icloud.com’s login is not accessible from any mobile device.
So what I came to conclude is that I might need to catch the users user-agent and if its a mobile platform redirect it to a disabled page?
I’m not really sure as to how to go about this, meaning could this be disabled via apache2 or a simple user-agent grabber using PHP or JS?
Advertisement
Answer
You can use a php class called http://mobiledetect.net/
JavaScript
x
19
19
1
// Include and instantiate the class.
2
require_once 'Mobile_Detect.php';
3
$detect = new Mobile_Detect;
4
5
// Any mobile device (phones or tablets).
6
if ( $detect->isMobile() ) {
7
8
}
9
10
// Any tablet device.
11
if( $detect->isTablet() ){
12
13
}
14
15
// Exclude tablets.
16
if( $detect->isMobile() && !$detect->isTablet() ){
17
18
}
19