dongyong8098 2012-06-22 22:22
浏览 38

自定义500错误php页面,再次在30秒后重试POST或GET表单?

We are trying to build a custom 500 error php page that retry the POST or GET form in 30 seconds again, we are using moodle for exams but sometimes we have a lot of students doing the same exam, any idea how to fix this problem? So far we can retry if the parameters are like xxx.php?name=doe but not if they come in an array form like $_post

<?php
    function my_url(){

        $url = (!empty($_SERVER['HTTPS'])) ?   "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

        echo "<meta http-equiv=\"refresh\" content=\"30;url=$url\"/>";
    }
    my_url();

?>
  • 写回答

1条回答 默认 最新

  • dsy6639 2012-06-22 22:29
    关注

    You can use Javascript (if the client has it enabled) to attempt to reload the page. This will resubmit the POST data. The problem is (in Firefox at least) when the script executes, the browser pops up asking if they would like to resubmit data so that could be confusing.

    This would work though:

    <script type='text/javascript'>
        setTimeout('window.location.reload()', 30000);
    </script>
    

    Depending on what type of POST data you have, you could convert all the POST fields to hidden elements and re-populate another form on the page and give them the option to re-submit it after some period of time. You wouldn't be able to attempt to re-upload any files they submitted, but normal form data should work.

    As Sam said in the comment, you could use similar code to resubmit the hidden form rather than calling window.location.reload(). This should prevent the "Are you sure you want to resubmit the data" popups most browsers will present.

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么