How can i detect the visitors IP Address using HTML for my website? I have a contactform.html and a formsent.html. And when formsent.html sends the contact info to my email i also want to see their IP Address!
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
$ip=$_SERVER['REMOTE_ADDR'];
this command shows server ip address not user local ip address because this is php command is complies the code in server because of that reason this command show server ip address
The following script may be useful to you. You can copy it and save it as
{whateveryouwant}.php
HTML is a markup language, so it doesn't have any variables.
If you want to get it using PHP, you'll need to make use of the $_SERVER superglobal variable. A solution could be:
This is the most basic however, and fails if the user is behind a proxy, as well as allowing them to trivially change it. A much much better method is to using something like:
(http://stackoverflow.com/questions/1634782/what-is-the-most-accurate-way-to-retrieve-a-users-correct-ip-address-in-php)
This correctly parses the HTTP_X_FORWARDED_FOR field as well as validating the IP to make sure it's of the right format, and not in a private block.
You can't.
HTML is a markup language, not a programming language. it doesn't "do" anything - it just structures content.
You need to use a programming language, such as PHP, ASP, etc.
You can't, not through HTML alone.
You need to use scripting that has the HTTP headers available to it.
See this SO answer using JSONP.
For PHP you would use
$_SERVER['REMOTE_HOST']
.You can't do it through HTML. However, you can find the IP address of a visitor through PHP.