一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

php限制用户60秒后发布评论实例代码

时间:2010-07-03 编辑:简简单单 来源:一聚教程网

// 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.111com.net否则必究

热门栏目