Jump to content

Archived

This topic is now archived and is closed to further replies.

devxtec

[Help] IP Logging

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.