Reputation: 7818
I have a simple PHP script that sends a message to a specified email address with content from a HTML form using the mail() function (which I am aware is prone to spam).
I was wondering if it's possible to obtain additional information about the user's settings and input them in the sent mail.
Additional information could contain:
If any of those are possible, that would be awesome.
Thanks, Amit
EDIT: Thanks to @Stephen, I was able to use the $_SERVER['HTTP_USER_AGENT'] to get more info regarding the browser. However, when using the get_browser, it did not work. This is my code:
$browser = get_browser(null, true);
$message = 'From: ' . "\n\n" .
'Name: ' . $_REQUEST['name'] . "\n\n" .
'E-mail: ' . $_REQUEST['email'] . "\n\n" .
'Comments: ' . $_REQUEST['comments'] . "\n\n" .
'Details: ' . $_SERVER['HTTP_USER_AGENT'] . "\n\n" .
'Further: ' . echo ($browser);
Anyone knows the reason why?
Thanks!
Upvotes: 0
Views: 343
Reputation: 6087
Many details can be found by parsing the $_SERVER['HTTP_USER_AGENT']
variable. Example for my current computer is:
echo $_SERVER['HTTP_USER_AGENT']
// Output: "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8"
Remember that the contents of this are not a definite sign - browsers can and do (sometimes deliberately, sometimes accidentally) lie about their origins.
Note there are some functions like get_browser which wrap the HTTP_USER_AGENT
to return some useful information too.
Upvotes: 2