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 adb push异常 adb: error: 1409-byte write failed: Invalid argument
  • ¥15 android报错 brut.common.BrutException: could not exec (exit code = 1)
  • ¥15 nginx反向代理获取ip,java获取真实ip
  • ¥15 eda:门禁系统设计
  • ¥50 如何使用js去调用vscode-js-debugger的方法去调试网页
  • ¥15 376.1电表主站通信协议下发指令全被否认问题
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥15 复杂网络,变滞后传递熵,FDA
  • ¥20 csv格式数据集预处理及模型选择
  • ¥15 部分网页页面无法显示!