Hello All, I would like to capture a users IP when they fill out a form. Once that form is submitted, I would like to also submit the IP as well. If the form I get via email contains spam, I'd like to deny that IP in my htaccess file. Can I get a sample PHP script to do this?
Do you wan't the whole process to be automatic, or can you manually modify the .htaccess file? Also one thing that's bad about this, is that someone can be using a proxy and you wouldn't be banning their actual IP. //ipaddress $ipAddress = $_SERVER['REMOTE_ADDR']; mail("your@email.com", "IP ADDRESS", $ipAddress); PHP:
Yes. Is there any way to "fool proof" this, so even beginner to intermediate hacks can't get around this?
Yes, I have access to htaccess (preferred method). As PHP goes, please be patient with me! That 1st line ($ipAddress =) - that goes on my page w/the form? The second line of code (mail("your...") ) goes on my "submission page" - the one the form points to?
I would put all of it on the same page that processes the form data. This way there is less chance of a user trying to manipulate the data. I don't know of any way to get around proxies. You could try to integrate with a system like http://www.projecthoneypot.org/. This way you can prevent bad IP's from even accessing your site in the first place.