Jump to content

Recommended Posts

I have a site set up that users can sign into and then submit a form to a database.  I want users to be able to access the logged-in site from a mobile browser or regular browser, but I need to put some code into the PHP form such that their submission is rejected if they did NOT submit it using a mobile browser (iPhone, Blackberry, Pre, whatever).  Suggestions?

Link to comment
https://forums.phpfreaks.com/topic/174281-recognizing-mobile-browsers/
Share on other sites

I want users to be able to access the logged-in site from a mobile browser or regular browser, but I need to put some code into the PHP form such that their submission is rejected if they did NOT submit it using a mobile browser

 

When you say you want users to be able to access with a "regular browser", but you then want to reject their submission, that makes no sense to me.

 

Anyway, you might be able to utilize the CSS "@media" rule to make it such that the form is only displayed for mobile browsers int he first place since there is a type of "handheld" that is recognized. Basically the CSS can specify different style sheet properties based on the media type of the output. So, for a "handheld" type you would set the display property of the form to be displayed, if not a handheld then make the display none.

One way I once tried back in the past was to write a bit of javascript to put the screen width into a hidden field in the form.  When the form gets submitted, use PHP to see what the screen width is.  If its less than 800 pixels, then its probably a mobile device.

 

However, now many mobile devices have bigger screen resolutions, that's probably not as effective as it once was.

Hi sc00tz,

 

A quick Google came across this website http://detectmobilebrowsers.mobi/

 

It has a function generator which will allow you to choose how you want to treat each individual mobile device, and also has a redirect option if people are using a regular browser.

 

I agree with mjdamato in that it's pointless showing the form to users using regular browsers if they are unable to submit.  I would suggest using the above and redirecting them to a custom page which shows a message along the lines of "You must be using amobile device to view this page"

 

Hope this helps.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.