How to add ip-addresses into my database table?

Hi all,
I have to know the users those are accessed/visited my site…
I want to know the IP-addresses of those users and store it into my database table and flush that table records automatically after 1week or 10 days…

Give me any live example to implement it.

Thanking you…

Hi

create another table with three columns
the id of the user(foreign key)
the ip
and a time stamp.

the relationship must be many to one user because a single user may be able to log in using different ip’s.

now in your code every time a user logs in capture his ip by inserting it into the table

you can get the ip with $ip=@$REMOTE_ADDR; or $ip=$_SERVER[‘REMOTE_ADDR’];

To delete you can either delete it from the log on page, so when a user logs in you delete all records older that ten days. else create a stored procedure and schedule it to run every day

to delete run
delete from <my table> where DATE_ADD(<your date column>, INTERVAL 1 DAYS) < NOW()

I recommend creating a stored procedure as its better for performance.