Results 1 to 3 of 3
Jul 1, 2009, 16:34 #1
- Join Date
- Nov 2004
- 0 Post(s)
- 0 Thread(s)
Capturing IP address & blocking IP address
I'm using a php script for my web site which has registration, log-in, etc.
When I asked how I might be able to capture the registrants IP address upon registration, I was given this code and this advice:
$userip = $_SERVER[REMOTE_ADDR]; mysql_real_escape_string($userip);
I don't know what INET_ATON() and INET_NTOA() are, but my goal is to be able to have a users IP address just in case he spams my site, then he can be blocked, based on the thinking that typically one user has one computer.
Can someone tell me how I can block an Ip address?
Any thoughts/replies/suggestions will be welcome. Thanks
Jul 1, 2009, 17:23 #2
You don't have to use these functions at all. You can just insert the actual ip address into the database.
These functions will just confuse you because they will convert a 'normal looking' ip address into a numerical value. What are the benefits to doing that?
I am not sure, but I think these may also be specific to mysql and not a standard SQL functions, so if you ever decide to switch to a different database you may have to not only change your code, but to also convert all your stored ip addresses back to their normal format.
If it makes you feel more secure, you can still use mysql_real_escape_string() before inserting the ip address.
Jul 1, 2009, 17:31 #3
Blocking a user via IP address is not very effective, honestly. IP addresses don't uniquely identify users, they are shared. Not only that but dial-up users almost always get a new IP every time the get online. There is also proxies and NAT that might combine a dozen users under a single IP.Logic without the fatal effects.
All code snippets are licensed under WTFPL.