Jump to content

[Help] IP Logging


devxtec

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.