作者:拍友2502920603 | 来源:互联网 | 2018-07-16 15:54
ec(2);<?php教程限制用户60秒后发布评论实例代码*createtable`test`.`abc`(`id`int(4)notnullauto_increment,`times`int(4)notnulldefault0,`ip`varchar(200)nulldefaultnull,primary
// php教程限制用户60秒后发布评论实例代码
/*
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教程_connect('localhost','root','root') or die('mysql server 2001');
mysql_select_db('test',$conn);
$date = time();
$ip = $_server['remote_addr'];//获取ip地址,这是测试所以没作判断了
$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('坐下来休息一下吧,您的动作太快了,请60秒后再发布你的信息!');
}
else
{
$sql = "insert into abc(times,ip) values('$date','$ip')";
$insert = mysql_db_query('test',$sql,$conn);
if( $insert )
{
echo '评论成功';
}
else
{
echo '评论失败';
}
}
}
?>
本站原创文章转载注明来源于www.111cn.net否则必究