;?
//php tutorial limits user 60 seconds post Comment Instance code
/*
CREATE TABLE ' test '. ' abc ' (
' id ' int (4) NOT NULL auto_increment,
' time S ' int (4) NOT null default ' 0 ',
' IP ' varchar null default NULL,
Primary key (' ID ')
) engine = Myi Sam
*/
if ($_post)
{
$conn = mysql tutorial _connect (' localhost ', ' root ', ' root ') or Die (' MySQL server 2001 ' );
mysql_select_db (' Test ', $conn);
$date = time ();
$ip = $_server[' remote_addr '];//get IP address, this is a test so it's not judged.
$wait = "Select TIMES,IP from ABC where ip= ' $ip ' and ($date-times<60) Order BY id DESC limit 1 ";
$rows = mysql_query ($wait) or Die (Mysql_error ());
if (mysql_num_rows ($rows))
{
Die (' Sit down and have a rest, you move too fast, please release your message in 60 seconds! ');
}
Else
{
$sql = "INSERT INTO ABC (TIMES,IP) VALUES (' $date ', ' $ip ')";
$insert = mysql_db_query (' Test ', $sql, $conn);
if ($insert)
{
Echo ' comment success ';
}
Else
{
Echo ' comment failed ';
}
}
}
?>
<form name= "Form1" method= "Post" action= "" >
<label for= "TextField" ></label>
<input type= "text" name= "www111cnnet" id= "TextField" >
<input type= "Submit" name= "button" id= "button" value= "comment" >
</form>
Original articles reproduced in this site is indicated from www.111cn.net otherwise must investigate