PHP标头重定向重新加载HTML页面上的相同部分,而不是使用ID的HTML页面上的另一部分

时间:2014-05-09 02:08:19

标签: php html redirect

我正在创建一个涉及PHP重定向的网站,但是当我使用标题函数重定向时,它不会重定向到正确的ID,它只是重定向到没有id的页面。

应该重定向到:

header('Location: '.$findHttp.'://'.$_SERVER["HTTP_HOST"].'/~a7068104/2013-2014/Lab_13/Reports/Reports.php#redirect');

但它实际上重定向到:

header('Location: '.$findHttp.'://'.$_SERVER["HTTP_HOST"].'/~a7068104/2013-2014/Lab_13/Reports/Reports.php');

你能告诉我为什么会这样吗?

以下是完整的PHP代码:

<?php
if (isset($_POST['reportsubmit'])) {
    $radio = $_POST['customer'];
    if ($radio == 'customer') {
        $redirect = 'Click <a href="#customer">here</a> to continue on with the form';
    } else if ($radio == 'item') {
        $redirect = 'Click <a href="#item">here</a> to continue on with the form';
    } else if ($radio == 'department') {
        $redirect = 'Click <a href="#department">here</a> to continue on with the form';
    } else if ($radio == 'person') {
        $redirect = 'Click <a href="#person">here</a> to continue on with the form';
    }
    $findHttp = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http';
    header('Location: '.$findHttp.'://'.$_SERVER["HTTP_HOST"].'/~a7068104/2013-2014/Lab_13/Reports/Reports.php#redirect');
    exit;
} else if (isset($_POST['customersubmit'])) {
    //process form
    //redirect
    exit;
} else if (isset($_POST['itemsubmit'])) {
    //process form
    //redirect
    exit;
} else if (isset($_POST['departmentsubmit'])) {
    //process form
    //redirect
    exit;
} else if (isset($_POST['personsubmit'])) {
    //process form
    //redirect
    exit;
}
?>

1 个答案:

答案 0 :(得分:0)

可以使用GET功能吗? 就像那样。

header('Location: http://'.$_SERVER["HTTP_HOST"].'/~a7068104/2013-2014/Lab_13/Reports/Reports.php?id=redirect');
相关问题