I have searched around but I am not very experienced with PHP. The script I have at the moment is
<?php
$to = "my email address";
$subject = "Report for broken link";
$id= $_GET['id'];
$body = "Link ID: $id";
if (mail($to, $subject, $body)) {
echo("<p>Message sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
?>
So basically it is for a user of the site to report a broken link, but I expect this is very easily exploitable as everytime I refresh the .php page an e-mail is sent.
As in the question title, I am looking for a way to limit use of the .php file to once per day (or per x hours) per user. What is the easiest way to do this?
EDIT: or, if you have a better idea for a solution, please let me know!
EDIT AFTER HAVING SOLVED:
For those interested in the solution to this, I have used the following (it seems to work, but if anyone can see any glaring holes in it please post her):
<?php
$to = "my email address";
$subject = "Report for broken link";
$id= $_GET['id'];
$body = "Link ID: $id";
if(isset($_COOKIE['noaccess'])) {
echo ("<p>Message already sent!</p>");
} else {
if (mail($to, $subject, $body)) {
setcookie("noaccess", "2hrs", time()+7200);
echo("<p>Message sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
} }
?>
One thing you could try is after the email is sent store a timestamp in the user session or a browser cookie, and then when the script is invoked again, you can check to see if a timestamp is present and if yes, if it is higher than your email threshold (one day, x hours, etc…)