FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

browser info in a form

 


ftv_flung
How do I echo browser information in a form?

I just want to collect info about what browser is being used, version etc., possibly OS, resolution etc. and put this into a form so it sends browser info with the stuff they submit anyway.
imagefree
alternatively, why no the get the info from the page submitted. These is no need to first place this info into form and then send it to server. When the request is made to server, you can get the desired info, how? See below.


Code:


<?php
$browser_name="Unknown";
$agent = getenv("HTTP_USER_AGENT");
if (preg_match("/MSIE/i", "$agent"))
{
   $browser_name = "IE";
}

else if (preg_match("/Mozilla/i", "$agent"))
{
   $browser_name= "Netscape";
}
//the $browser_name variable now has the browser name. Someone else may be help you in detail.
?>


You can get browser name, version, OS, but cant get Screen resolution with php. i think you need to do it which javascript.
mahirharoon
imagefree wrote:
alternatively, why no the get the info from the page submitted. These is no need to first place this info into form and then send it to server. When the request is made to server, you can get the desired info, how? See below.


Code:


<?php
$browser_name="Unknown";
$agent = getenv("HTTP_USER_AGENT");
if (preg_match("/MSIE/i", "$agent"))
{
   $browser_name = "IE";
}

else if (preg_match("/Mozilla/i", "$agent"))
{
   $browser_name= "Netscape";
}
//the $browser_name variable now has the browser name. Someone else may be help you in detail.
?>


You can get browser name, version, OS, but cant get Screen resolution with php. i think you need to do it which javascript.

use instead
Code:
<?php
//echo user agent
echo "$_SERVER['HTTP_USER_AGENT']";
?>

edit :
Quote:
why are you pming me for questions , post here so other users would get help from that
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.