dtysql0586 2013-03-06 14:01
浏览 90
已采纳

PHP sleep()无法正常工作我希望重定向

I have a form, which on submit checks the data. if the data is invalid, I currently have it echoing text.

I want it to echo the text then pause and redirect.

I've tryed sleep(); but that causes the page to sleep on submit, wait x amount of seconds then continues without showing the echo's

Any idea of how to get around this

  • 写回答

2条回答 默认 最新

  • dpnvrt3119 2013-03-06 14:04
    关注

    Send out your error message nromally and use a meta refresh to do the redirecting after x amount of seconds:

    <?php
    
    // your code that determines there is an error goes here
    
    header('Refresh: 10;url=your_page.php');
    
    echo $errorMessage;
    

    The header() call is identical to this meta tag:

    <meta http-equiv="refresh" content="10;URL='your_page.php'">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 从Freecad中宏下载的DesignSPHysics,出现如下问题是什么原因导致的(语言-python)
  • ¥30 notepad++ 自定义代码补全提示
  • ¥15 MATLAB有限差分法解一维边值问题
  • ¥200 内网渗透测试 横向渗透 Windows漏洞 Windows权限维持
  • ¥15 数据结构图的相关代码实现
  • ¥15 python中aiohttp.client_exceptions.ContentTypeError
  • ¥30 DeepLung肺结节检测生成最大froc值对应的epoch报错
  • ¥15 信号发生器如何将频率调大,步尽值改成10
  • ¥15 keil 5 编程智能家具,风扇台灯开关,人体感应等
  • ¥100 找一名渗透方面的专家