Php limits users to publish comments to the instance code 60 seconds later-PHP source code

Source: Internet
Author: User
Ec (2); & lt ;? The php tutorial limits the user to publish the comment instance Code * createtable 'test' 60 seconds later '. 'abc' ('id' int (4) notnullauto_increment, 'times 'int (4) notnulldefault0, 'IP' varchar (200) nulldefaultnull, primary script ec (2 ); script

// Php tutorial limits the user to publish the comments instance code 60 seconds later
/*
Create table 'test'. 'abc '(
'Id' int (4) not null auto_increment,
'Times 'int (4) not null default '0 ',
'IP' varchar (200) null default null,
Primary key ('id ')
) Engine = myisam
*/
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 ']; // obtain the ip address. This is a test, so no judgment is made.
$ 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. Your actions are too fast. Please release your information 60 seconds later! ');
}
Else
{

$ SQL = "insert into abc (times, ip) values ('$ date',' $ ip ')";
$ Insert = mysql_db_query ('test', $ SQL, $ conn );
If ($ insert)
{
Echo 'comment successful ';
}
Else
{
Echo 'comment failed ';
}

}
}
?>


Original article reprinted on this site indicated that the source is www.111cn.net, otherwise it must be investigated

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.