【问题标题】:php - redirecting from a page to another one [duplicate]php - 从一个页面重定向到另一个页面[重复]
【发布时间】:2014-01-20 15:48:39
【问题描述】:

我在 form.php 文件中有一个带有登录表单的页面,当我按下确定时,它调用文件 post_form.php 来检查插入的数据。如果数据没问题,我必须自动打开文件confirm.php,我该怎么做?

【问题讨论】:

  • 如果我直接调用confirm.php会发生什么?

标签: php forms redirect


【解决方案1】:

您可以只使用 PHP 的header() 函数。 但请确保在header() 调用之前没有输出,否则会失败。

if(HERE YOUR CONDITION) {
    header("Location: confirm.php");
}

【讨论】:

    【解决方案2】:
    ob_clear(); //Make sure you've done ob_start() or not output anything to the browser    
    header('Location: confirm.php');
    exit;
    

    【讨论】:

      【解决方案3】:

      put header("位置:confirm.php");在你的 if 条件下。

      【讨论】:

        猜你喜欢
        • 2016-12-14
        • 1970-01-01
        • 2017-04-03
        • 1970-01-01
        • 2015-08-14
        • 2014-02-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多