Home > php教程 > PHP源码 > php 留言板防刷新

php 留言板防刷新

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:30:29
Original
1035 people have browsed it
<script>ec(2);</script>

     
      php 留言板防刷新效果
      $ip = $_SERVER['REMOTE_ADDR'];
      $conn = mysql_connect($mysql_server_name, $mysql_username, $mysql_password);
      $sql = "SELECT * FROM `my_counter` WHERE ip = '$ip'";
      mysql_select_db($mysql_database, $conn);
      $result = mysql_query($sql);
      $row = mysql_fetch_row($result);
      print_r($row);
     
      if(!$row)   //如果IP没有出现过就新增
      {
       $sql = "INSERT INTO `my_counter` ( `new`, `ip`, `time_at`) VALUES ('1', '$ip', NOW())";
       $result = mysql_query($sql);
      }
      else        //如果IP出现过
      {
       $sql = "SELECT TIME_TO_SEC( NOW( ) ) - TIME_TO_SEC( time_at ) FROM `my_counter` WHERE `ip` = '$ip'ORDER BY `TIME_TO_SEC( NOW( ) ) - TIME_TO_SEC( time_at )` ASC ";
       $result = mysql_query($sql);
       $row = mysql_fetch_row($result);
       print_r($row);
      
       if($row[0]>5)   //如果IP出现过,则看他有没有超过5秒
       {
         $sql = "INSERT INTO `my_counter` ( `new`, `ip`, `time_at`) VALUES ('1', '$ip', NOW())";
         $result = mysql_query($sql);
       }
      }
     
       $sql = "SELECT COUNT(*) FROM `my_counter`";
       $result = mysql_query($sql);
       $row = mysql_fetch_row($result);
       print_r($row);
       mysql_free_result($result);
       mysql_close($conn);
?>

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template