Is there any script to check user agent then send and save that information to database on server?
I\'m making mobile website with 2 versions like m.facebook.com
You might want to look into jQuery's take on this, since it's interesting.
In addition to detecting the browser, they detect browser features:
http://api.jquery.com/jQuery.browser/
http://api.jquery.com/jQuery.support/
Also, keep in mind that some mobile users don't want to be redirected to the mobile-optimized device. I, for one, positively hate it when a site detects my iPad as a mobile device and sends me (without any possibility to override it) to a sloppy mobile site that I wouldn't even want to browse with an iPhone.
iOS and Android devices, in general, will happily work with the standard site if it's coded properly. And other mobile phones are quickly dying.