PDA

View Full Version : How to store into variable javascript values?



toplisek
01-30-2011, 06:49 PM
I like to store into database with PHP values from Javascript. How to do this as I like to test local values from visitor.





<script type="text/javascript">

document.write("Browser CodeName: " + navigator.appCodeName);
document.write("<br /><br />");
document.write("Browser Name: " + navigator.appName);
document.write("<br /><br />");
document.write("Browser Version: " + navigator.appVersion);
document.write("<br /><br />");
document.write("Cookies Enabled: " + navigator.cookieEnabled);
document.write("<br /><br />");
document.write("Platform: " + navigator.platform);
document.write("<br /><br />");
document.write("User-agent header: " + navigator.userAgent);

</script>

Stooshie
01-31-2011, 10:56 AM
PHP has some global value that you can use. Check out: http://php.net/manual/en/reserved.variables.php for a description.

toplisek
01-31-2011, 10:58 AM
Can you post some sample please how to use in my example?

Stooshie
01-31-2011, 11:44 AM
The code you have is javascript. The php would be something like


<?php
echo($_SERVER["HTTP_USER_AGENT"]);
?>

toplisek
01-31-2011, 12:39 PM
Yes, I understand this. I like to double check clients data.
How to set + navigator.platform into variable to be read by PHP?
Example: $User-Agent

Kor
01-31-2011, 02:06 PM
Yes, I understand this. I like to double check clients data.
What makes you believe that the correspondent JavaScript variables could be others that the PHP's (or any other language's)?:rolleyes: They are the properties of the browser's unique "signature". Their values are the same, regardless the language you are using to read them. You will get the same user agent, the same platform..., etc. A server-side language is even more precise, as you can get the IP.