Hello, I'm using formmail script for the contact us form. But is there any way to capture the IP adress of the form submitters? Using the same script or by using additional one along with it..??? - N€O
You can get the user's IP using the environment variable REMOTE_ADDR or better still move to cforms (a highly configurable form script)
$_SERVER['remote_addr'] always contains USER's IP... so just post it to your form as hidden, or use it in final loaded script without any forms, that's better...
Sometimes, if a user is accessing your site through a proxy, the proxy will pass your site their real IP. This is stored in $HTTP_X_FORWARDED_FOR You should check if this is set and then, if it is, assume that to be their real IP, else, assume the IP given by $_SERVER['remote_addr'] to be the real IP. If you need any help scripting this, just ask. I hope I helped.
<input type="hidden" name="userIP" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>"> PHP: Add this code ( input field ) into your form ( no worries, it's invisible ) and whoalaa ..
I can use Proxy instead of editing hidden fields .. what you are going to do in that case ? From my point of view, if you do not add proxy verification, you can use both codes ( as there is no difference between them ).
Read my post from above: http://forums.digitalpoint.com/showpost.php?p=10686273&postcount=4 Also, using your method, to prevent possible code injections and other vulnerabilities, you will have to validate the IP in the PHP script anyway. Moreover that, what extra trouble is it having another line in a PHP script; than having 1 line to retrieve the IP from post/get, then validate it, and having an extra line in your HTML. Point taken?
Thanks guys... i got exactly what i was looking for... Thanks Google... Check out http://www.tol.it/doc/formmail/formmail-howto.htm#env_report