1. <i id='6hu6q'><tr id='6hu6q'><dt id='6hu6q'><q id='6hu6q'><span id='6hu6q'><b id='6hu6q'><form id='6hu6q'><ins id='6hu6q'></ins><ul id='6hu6q'></ul><sub id='6hu6q'></sub></form><legend id='6hu6q'></legend><bdo id='6hu6q'><pre id='6hu6q'><center id='6hu6q'></center></pre></bdo></b><th id='6hu6q'></th></span></q></dt></tr></i><div id='6hu6q'><tfoot id='6hu6q'></tfoot><dl id='6hu6q'><fieldset id='6hu6q'></fieldset></dl></div>

    • <bdo id='6hu6q'></bdo><ul id='6hu6q'></ul>
  2. <small id='6hu6q'></small><noframes id='6hu6q'>

      <legend id='6hu6q'><style id='6hu6q'><dir id='6hu6q'><q id='6hu6q'></q></dir></style></legend>
    1. <tfoot id='6hu6q'></tfoot>

      在 PHP 中重定向而不使用 header 方法

      Redirect in PHP without use of header method(在 PHP 中重定向而不使用 header 方法)
      <tfoot id='dUqNW'></tfoot>
      <i id='dUqNW'><tr id='dUqNW'><dt id='dUqNW'><q id='dUqNW'><span id='dUqNW'><b id='dUqNW'><form id='dUqNW'><ins id='dUqNW'></ins><ul id='dUqNW'></ul><sub id='dUqNW'></sub></form><legend id='dUqNW'></legend><bdo id='dUqNW'><pre id='dUqNW'><center id='dUqNW'></center></pre></bdo></b><th id='dUqNW'></th></span></q></dt></tr></i><div id='dUqNW'><tfoot id='dUqNW'></tfoot><dl id='dUqNW'><fieldset id='dUqNW'></fieldset></dl></div>

        <legend id='dUqNW'><style id='dUqNW'><dir id='dUqNW'><q id='dUqNW'></q></dir></style></legend>
          <bdo id='dUqNW'></bdo><ul id='dUqNW'></ul>

                <tbody id='dUqNW'></tbody>

                <small id='dUqNW'></small><noframes id='dUqNW'>

                本文介绍了在 PHP 中重定向而不使用 header 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                此contact.php 表单正在处理提交,然后重定向到新页面,然后突然停止工作.我尝试添加错误处理并将标题移动到所有其他标题的顶部,但两者都不起作用.表单仍在按预期提交数据,只是重定向不起作用.任何想法将不胜感激.

                This contact.php form was working to handle a submit and then redirect to a new page and then all of a sudden just stopped working. I have tried adding error handling and also moving header to the top in front of all other, but neither works. The form is still submitting the data as expected, it's just the redirect that doesn't work. Any ideas would be appreciated.

                <?php 
                include 'config.php';
                $post = (!empty($_POST)) ? true : false;
                if($post)
                {
                    $email = trim($_POST['email']);
                    $subject = "Downloaded Course Units";
                    $error = '';
                    if(!$error)
                    {
                        $mail = mail(WEBMASTER_EMAIL, $subject, $message, 
                        "From: ".$email."
                "
                        ."Reply-To: ".$email."
                "
                        ."X-Mailer: PHP/" . phpversion());
                        if($mail)
                        {
                            echo 'OK';
                            header('location: http://www.google.com.au/');
                            exit();
                        }
                    }
                }
                ?>
                

                推荐答案

                使用javascript.

                Use javascript.

                代替

                header('location: http://www.google.com.au/');
                

                使用,

                ?>
                <script type="text/javascript">
                window.location.href = 'http://www.google.com.au/';
                </script>
                <?php
                

                即使你的浏览器有输出,它也会重定向.

                It will redirect even if something is output on your browser.

                但是,要采取一项预防措施:即使页面上打印了某些内容,Javascript 重定向也会重定向您的页面.

                But, one precaution is to be made: Javascript redirection will redirect your page even if there is something printed on the page.

                确保它不会跳过任何用 PHP 编写的逻辑.

                Make sure that it does not skip any logic written in PHP.

                这篇关于在 PHP 中重定向而不使用 header 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                PHP Upload File Validation(PHP 上传文件验证)
                PHP Error - Uploading a file(PHP 错误 - 上传文件)
                How can I write tests for file upload in PHP?(如何在 PHP 中编写文件上传测试?)
                php resizing image on upload rotates the image when i don#39;t want it to(php在上传时调整图像大小会在我不想要它时旋转图像)
                How to send additional data using PLupload?(如何使用 PLupload 发送附加数据?)
                change button text in js/ajax after mp4 =gt;mp3 conversion in php(在 php 中的 mp4 =gt;mp3 转换后更改 js/ajax 中的按钮文本)
                  <bdo id='WIeUK'></bdo><ul id='WIeUK'></ul>
                    <tbody id='WIeUK'></tbody>
                    • <small id='WIeUK'></small><noframes id='WIeUK'>

                      <i id='WIeUK'><tr id='WIeUK'><dt id='WIeUK'><q id='WIeUK'><span id='WIeUK'><b id='WIeUK'><form id='WIeUK'><ins id='WIeUK'></ins><ul id='WIeUK'></ul><sub id='WIeUK'></sub></form><legend id='WIeUK'></legend><bdo id='WIeUK'><pre id='WIeUK'><center id='WIeUK'></center></pre></bdo></b><th id='WIeUK'></th></span></q></dt></tr></i><div id='WIeUK'><tfoot id='WIeUK'></tfoot><dl id='WIeUK'><fieldset id='WIeUK'></fieldset></dl></div>

                        1. <legend id='WIeUK'><style id='WIeUK'><dir id='WIeUK'><q id='WIeUK'></q></dir></style></legend><tfoot id='WIeUK'></tfoot>