不能修改报头信息-报头已经由上述行以Html开头发送



警告:无法修改标头信息-标头已经由(输出开始于C:wamp64wwwprojindex.php:2)在C:wamp64wwwprojmenuedit.php第8行

index . php

<?php include_once "includes/functions.php";?>
<!DOCTYPE html>
<html>
<head>

edit。

$id = $_GET['id'];
$menu = getmenu($id);
if (isset($_POST['btn']))
{
$data = $_POST['frm'];
edit_menu($data,$id);
header("location:index.php?m=menu&p=list");
}

有人能帮我吗?顺便说一下,数据库正在更新,没有问题。

我在网上找到了这个函数,它帮助了我!

function safe_redirect($url, $exit=true) {

// Only use the header redirection if headers are not already sent
if (!headers_sent()){

header('HTTP/1.1 301 Moved Permanently');
header('Location: ' . $url);

// Optional workaround for an IE bug (thanks Olav)
header("Connection: close");
}

// HTML/JS Fallback:
// If the header redirection did not work, try to use various methods other methods

print '<html>';
print '<head><title>Redirecting you...</title>';
print '<meta http-equiv="Refresh" content="0;url='.$url.'" />';
print '</head>';
print '<body onload="location.replace(''.$url.'')">';

// If the javascript and meta redirect did not work, 
// the user can still click this link
print 'You should be redirected to this URL:<br />';
print "<a href="$url">$url</a><br /><br />";

print 'If you are not, please click on the link above.<br />';    

print '</body>';
print '</html>';

// Stop the script here (optional)
if ($exit) exit;
}

src: https://www.jonasjohn.de/snippets/php/secure-redirect.htm#:~:text=This%20little%20function%20ensures%20that,link%20to%20the%20new%20URL.

最新更新