Jump to content


Photo

[Help] IP Logging


  • Please log in to reply
3 replies to this topic

#1 devxtec

devxtec
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 08 April 2006 - 05:13 AM

I'm slightly new to php and I've been looking all over for tutorials on how to do what I'm trying to do and haven't found anything yet.

I'm trying to take a contact form I made using php and make it so that it will only allow a visitor the ability to fill out the form and send it once every 15 minutes. How can implement this using php?


#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 08 April 2006 - 09:35 AM

in the form that teh user fills in have...

<input type="hidden" name="IPADDY" id="IPADDY" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>">

now on submission of the form have a table to log ipaddy and the time...

$query = mysql_query("INSERT INTO `iplog` (`ipaddy`,`time`) VALUES ('" . $_POST['IPADDY'] . "', '" . mktime() . "');

before you add that line query the table for that ipaddress and se if the corresponding time is > (mktime() - (60 * 15)) if it is they tried less than 15 mins ago so display a message telling thme so. If not process the formand add that info to your log table.
follow me on twitter @PHPsycho

#3 devxtec

devxtec
  • Members
  • PipPip
  • Member
  • 27 posts

Posted 08 April 2006 - 06:58 PM

Thanks for the quick reply. I'll give it a shot! =D

#4 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 14 April 2006 - 01:10 AM

Not a good idea to pass the IP from the form. Someone could easily create a form on their desktop that passes anything they want to your page and still spam it. Better to obtain the IP address from $_SERVER['REMOTE_ADDR'] on the page that processes the form or use sessions.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users