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 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <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>