doutan1875 2011-11-29 10:17
浏览 40

当PHP计数器达到x访问者限制时,重定向到新页面

I am very new to this, It s for a project for school. (I don t know php, only playing with flash for design)

I am using a php code loaded in my flash webpage to count the number of visitors. What do I have to add for when the counter reaches a X number of visitors to redirect to different page or part of the flash webpage) btw it has an output I think, as it sends the number of visitors to be showed on the website thru a Dynamic Text

<?     
    $filename = "PHPCounter.txt"; 
    $fp = fopen( $filename,"r");             
    $Old = fread($fp, 100);
    fclose( $fp );
    $Old = split ("=", $Old, 5);        
    $NewCount = $Old[1] + '1';        
    $New = "myCount=$NewCount";        
    $fp = fopen( $filename,"w+");         
    if (flock($fp, 2)) { 
      fwrite($fp, $New, 100);
    }         
    fclose( $fp );

    print "myCount=$NewCount";     
?>
  • 写回答

1条回答 默认 最新

  • dsxmwin86342 2011-11-29 10:20
    关注

    to redirect to a new page:

    header("Location: newpage.php");
    

    Make sure there is no output to the browser before this function happens, otherwise it won't work.

    So after X number of views (I've used 100 as an example):

    if ($NewCount >= 100) {
      header("Location: newpage.php");
      exit();
    }
    

    Not sure how you'd go about directing it to a specific part of the flash, don't know if thats even possible. My flash isn't really up to scratch, sorry.

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?