2008/11/07
| |
<?php session_start(); ?>
<title>通过session禁用页面刷新</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
-->
</style>
<center>
<?php
  if($_SESSION[temp]==""){
   if(($fp=fopen("count.txt","r"))==false){
    echo "打开文件失败!";
      }else{
    $counter=fgets($fp,1024);      //读取文件中数据
       fclose($fp);                        //关闭文本文件
       $counter++;                         //计数器增加1
       $fp=fopen("count.txt","w");       //以写的方式打开文本文件
    fputs($fp,$counter);                //将新的统计数据增加1
       fclose($fp);      //关闭文件
   }                    
         if(($fp=fopen("count.txt","r"))==false){
    echo "打开文件失败!";
   }else{
          $counter=fgets($fp,1024);
          fclose($fp);
             echo "数字计数器: " .$counter ;    //输出访问次数
   }
     $_SESSION[temp]=1;  //登录以后,$_SESSION[temp]的值不为空,给$_SESSION[temp]赋一个值1
   }else{
     echo "<script>alert('您不可以刷新本页!!'); history.back();</script>";
   if(($fp=fopen("count.txt","r"))==false){
    echo "打开文件失败!";
   }else{
    $counter=fgets($fp,1024);
    fclose($fp);
    echo "网页访问量: " .$counter ;   //输出访问次数
   }
    }
?>
</center>
Tags: ,
发表评论
表情
emotemotemotemot
emotemotemotemot
emotemotemotemot
emotemotemotemot
emotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]
               

 
Theme by Marshal. Powered by Bo-Blog 2.1.1 ReleaseCode detection by Bug.Center.Team