PHP头位置不匹配';行不通

PHP头位置不匹配';行不通,php,Php,我在标题重定向方面有点问题。我试着这样做,但它没有重定向。我检查了声明和所有说明是否正确。只有重定向不起作用,我不知道为什么 <!DOCTYPE html> <html class="full" lang="en"> <head> <?php include 'html/head.html'; ?> <link href="css/the-big-picture.css" rel="stylesheet"> </

我在标题重定向方面有点问题。我试着这样做,但它没有重定向。我检查了声明和所有说明是否正确。只有重定向不起作用,我不知道为什么

<!DOCTYPE html>
<html class="full" lang="en">

<head>
    <?php include 'html/head.html'; ?>
    <link href="css/the-big-picture.css" rel="stylesheet">
</head>

<body>

<?php include 'html/nav.html';
session_start();
if(isset($_POST['returnItem'])){
    $connection = mysqli_connect("localhost", "root", "stdinv2016", "invbook");
    $query = "SELECT id_wypozyczenia, nazwa_przedmiotu, nr_fabryczny_przychodu,imie_nazwisko, data_wypozyczenia FROM `wypozyczenia` WHERE id_wypozyczenia=".$_POST['returnItem'];
    $connection->set_charset("utf8");
    $result = mysqli_query($connection, $query, $resultmode = MYSQLI_STORE_RESULT) or die("Query fail: " . mysqli_error());
    if ($result->num_rows < 1)
    {
        echo '<div class="alert alert-dismissible alert-danger col-lg-4 col-lg-offset-4" align="center">
        <strong>Aktualnie żaden sprzęt nie został wypożyczony</strong><br> Spróbuj jeszcze raz. <br></div>';
    }
    else{
        echo "<div class='col-lg-offset-3 col-lg-6'>
    <div class='well bs-component'>
    <div class='alert alert-dismissible alert-warning'>
    <strong><p align='center'>Czy na pewno chcesz zatwierdzić zwrot poniższego przedmiotu?</p></strong>
    </div>
        <div class=\"table table-striped table-hover\">";
                echo "<table class=\"table\"><tr><th>ID</th><th>Nazwa przedmiotu</th><th>Nr inwentarzowy<th>Wypożyczający<th>Data wypożyczenia</th></tr>";
                // output data of each row
                    $row = $result->fetch_assoc();
                    echo "<tr><td>" . $row['id_wypozyczenia'] . "</td><td>" . $row['nazwa_przedmiotu'] . "</td><td>" . $row['nr_fabryczny_przychodu'] . "</td><td>" .$row['imie_nazwisko'] . "</td><td>" . $row['data_wypozyczenia']. "</td></tr>";

                echo "</table>

                </div>
                <form method='post' action='confirmReturn.php'>
                <div align='center'>
                <input type='hidden' name='invNumber' value=".$row['id_wypozyczenia'].">
                <button class='btn btn-success' type='submit' name='confirmReturn' value='yes'>Tak</button>
                <button class='btn btn-danger' type='submit' name='confirmReturn' value='no'>Nie</button>
                </form>
                </div>
                </div></div>";
    }
}
else if(isset($_POST['confirmReturn']) && $_POST['confirmReturn']=='yes'){
    //print_r($_POST);
    /*$connection = mysqli_connect("localhost", "root", "stdinv2016", "invbook");
    $query = "SELECT id_wypozyczenia, nazwa_przedmiotu, nr_fabryczny_przychodu,imie_nazwisko, data_wypozyczenia FROM `wypozyczenia` WHERE id_wypozyczenia=".$_POST['returnItem'];
    $connection->set_charset("utf8");
    $result = mysqli_query($connection, $query, $resultmode = MYSQLI_STORE_RESULT) or die("Query fail: " . mysqli_error());
    if ($result->num_rows < 1)
    {
        echo '<div class="alert alert-dismissible alert-danger col-lg-4 col-lg-offset-4" align="center">
        <strong>Aktualnie żaden sprzęt nie został wypożyczony</strong><br> Spróbuj jeszcze raz. <br></div>';
    }*/
}
else if(isset($_POST['confirmReturn']) && $_POST['confirmReturn']=='no'){
    header("location: returnItem.php");
}
else{
header("location: returnItem.php");
}



include 'html/scripts.html'; ?>
</body>
</html>

记住,必须在调用任何实际输出之前调用header()
通过普通HTML标记、文件中的空行或PHP发送。
使用include或require读取代码是非常常见的错误,
函数或其他文件访问函数,并具有空格或空
在调用header()之前输出的行。同样的问题
使用单个PHP/HTML文件时存在

源于

记住,必须在调用任何实际输出之前调用header() 通过普通HTML标记、文件中的空行或PHP发送。 使用include或require读取代码是非常常见的错误, 函数或其他文件访问函数,并具有空格或空 在调用header()之前输出的行。同样的问题 使用单个PHP/HTML文件时存在


源于

写入退出的可能副本;在标题之后(“位置:returnItem.php”);在底部包含一些文件是没有意义的;在标题之后(“位置:returnItem.php”);在底部包含一些文件是没有意义的。好的。我读过这篇文章。是我的错。现在我知道如何解决这个问题了。谢谢你的回答。我读过这篇文章。是我的错。现在我知道如何解决这个问题了。谢谢你的回答。