I'm using a php script for my web site which has registration, log-in, etc. Can you tell me how I might be able to capture the registrants IP adress upon registration? Thanks.
Thanks for your reply. If I add $ip = $_SERVER[REMOTE_ADDR]; to my registration page and add a corresponding field in my database, this will allow me to capture the IP address of the regisrtant? Should the db field be named REMOTE_ADDR ? Obviously I could use some more information. Any additional enlightening would be appreciated.
Excluding reserved words, you can name the database field anything you want. It doesn't have to be 'REMOTE_ADDR', but if that will help you associate it with the registrant's IP address use it. Also, I don't know why you need to store this in a database, but I would be leary of using it to verify the user. I use multiple computers throughout the day/week each with its own IP address and would be mad if I couldn't log onto a site because I wasn't at the right computer.
Thanks for your reply. I just wanted to capture a users IP address just in case he spams my site, then I could possibly block him, with the thinking that most people use one computer. I don't want to use it as a requirement to log in. A user will just need his user name & password. I look forward to any thoughts/replies regarding this. Thanks.
if your site requires logins use something like this. $ip = $_SERVER[REMOTE_ADDR]; $ipselect="select id from user_ips where ip='$ip' and user='$user'"; $ipquery=mysql_query($ipselect); $rows=mysql_num_rows($ipquery); if($rows<=0){ $sql="INSERT INTO user_ips (user,ip)VALUES('$user,'$ip')" or die(mysql_error()); $query=mysql_query($sql) or die(mysql_error()); } PHP: That way, whenever your user uses a different IP it will be added. even if a user is on a dynamic ip systems you could narrow things down by the octets on the history. Its something I built personally. I do not know if it is the best way of doing things but I figured i share it. You can even go as far as adding dates or timestamps which I should do. Anyway, something to dabble with. enjoy