Click to See Complete Forum and Search --> : JavaScript IP Detection
7Priest7
July 12th, 2007, 04:41 PM
I keep finding this
var ip = '<!--#echo var="REMOTE_ADDR"-->';
It doesent work!!!
I need JavaScript IP detection that works!!
I thought there would be some kind of variable like navigator.something.another
But I can't find it...
Maybe some1 will know??
Please Help
Alex
PeejAvery
July 12th, 2007, 04:58 PM
JavaScript can't detect the IP address. The code you were trying to implement is part of a server-side predefined variable. You can use a server-side language to echo the IP to a JavaScript variable
<script type="text/javascript">
var ip = "<?php echo $_SERVER['REMOTE_ADDR']; ?>";
</script>
7Priest7
July 12th, 2007, 10:27 PM
The PHP didnt work...
I think it is for the following reason...
I have my main files (index.htm source.htm and download.htm)
I think they are not allowing Server Side Features
I would have to rename them to (index.php source.php and download.php)?
The reason I am trying to avoid it is because...
Google will keep invalid Links
Any suggestions to avoid the rename?
Alex
PeejAvery
July 13th, 2007, 08:18 AM
You don't have to rename files. The operation of PHP depends on the server configuration.
1. You must be running your page from a web server and not a client.
http://webserver/
not
C:\path\to\web\folder
2. You must have PHP installed on that server.
3. If you want htm or html as a file extension that recognizes PHP, you must edit the following line in the httpd.conf file.
AddType application/x-httpd-php .php .html
andreasblixt
July 13th, 2007, 09:00 AM
3. If you want htm or html as a file extension that recognizes PHP, you must edit the following line in the php.ini file.
AddType application/x-httpd-php .php .html
That'd be either httpd.conf (global configuration) or .htaccess (local configuration) of Apache. For IIS this can be done in Properties > Home Directory > Configuration...
php.ini only holds settings for when the PHP parser is running.
PeejAvery
July 13th, 2007, 09:36 AM
Ha. I knew that. Thanks for catching my mistake!
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.