Okay, here are two samples:
1: Cookie method (not invisible, but it works
)
PHP Code:
<?php
if(isset($_COOKIE['survey'])){
die("You already sent in the survey");
}else{
//process form
setcookie("survey", 'set', time()+(60*60*24*30)); //cookie expires in one month
}
?>
2:MySQL method:
PHP Code:
<?php
$ip = $_SERVER['REMOTE_ADDR'];
//connect to MySQL
$rows = MySQL_Query("SELECT * FROM sent WHERE ip=\"$ip\";");
if(MySQL_Num_rows($rows) > 0){
die("You already sent in the survey");
}else{
//process form
MySQL_Query("INSERT INTO sent VALUES (\"$ip\");");
}
//close mysql connection
?>
The difference is that the information in number 1 is store on the user's computer, number 2 is on the server. In number 1, if the user clears their cookies, they can resubmit the form. In number 2, if they have a dynamic IP (most people do), if they reset their router, they can resubmit the form.
Bookmarks