简体   繁体   English

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

[英]PHP header redirect is reloading the same part on the HTML page as opposed to another part on the HTML page using ids

I'm making a website that involves PHP redirects, but when I redirect with the header function it doesn't redirect to the right id it just redirects to the page without the id. 我正在制作一个涉及PHP重定向的网站,但是当我使用标头函数重定向时,它不会重定向到正确的ID,它只会重定向到没有ID的页面。

It is supposed to redirect to: 它应该重定向到:

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

But it actually redirects to: 但实际上它重定向到:

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

Can you please tell me why that is? 你能告诉我为什么吗?

Here is the full PHP code: 这是完整的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;
}
?>

is it possible to work with GET function? 可以使用GET功能吗? Like that. 像那样。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使HTML页面的一个区域重定向到另一URL,而页面的其余部分保持不变? - How to make one area of a html page redirect to another url while the rest part of the page stay same? 在HTML中嵌入php,以将标头(页面顶部)包含到页面中 - embedded php in html to include header (top part of page) into the page 如何使用 php 将数据传递到我的 html 页面的另一部分? - How to pass data to another part of my html page with php? 将HTML页面的一部分下载为文本(PHP) - Download part of HTML page as text (PHP) 如何链接到页面的特定部分 HTML PHP - How to link to a specific part of a page HTML PHP 使用JavaScript重新加载页面(或页面的一部分) - Reloading a Page (or part of a page) using JavaScript 如何使用 php header 重定向到 html 页面中的特定表单? - How to redirect to a particular form in html page using php header? 将不属于表单的HTML页面中的值传递给php页面 - pass a value from HTML page which is not part of a form to a php page 如何重定向到 PHP 中的特定页面部分,如 Html 我们通过 Id="abc" 然后我们执行<a>href="#abc"</a> - How To redirect To A specific Part of page in PHP like in Html We it By Id="abc" and then we do <a>href="#abc"</a> 如何在HTML页面的标题部分包含登录表单 - How to include a login form in the header part of the html page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM