Log users ip/use it to block them for length of time

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
decoy1
Forum Commoner
Posts: 50
Joined: Fri Feb 21, 2003 1:33 pm
Location: St. Louis

Log users ip/use it to block them for length of time

Post by decoy1 »

I would like to be able to log a visitors IP address after submitting a form. Then associate the current time with the IP address when it was logged and not allow that particular address to submit the same form again for 24 hours.

I can get the IP and know how to get the current time obviously, but I'm struggling to find the best way to do this. I have a couple of ideas but they seem overly complicated.

I'm already setting a cookie when a visitor initially visits otherwise I would set a cookie with the current time.

Was wondering if someone might offer me some suggestions.

Thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

do you have a database at hand?
if so you might store the ip and a timestamp. When the form is submitted you query the recordset(s) having the ip and a timestamp within a certain timespan. If there is such a record you block the submission. If not the request is accepted and the new timestamp is updated/inserted.
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Don't forget that some ISPs change their users IP address everytime that person connects to the web. Someone visiting your site might not have the same IP address next time they visit.
Post Reply