与服务器的连接在页面加载php错误时重置


The connection to the server was reset while thepage was loading php error

<?php
session_start();
include 'dbConnection.php';
?>
<!DOCTYPE HTML>
<html>
<head>
    <title>Online Book Club</title>
</head>
<body>
    <form method ="post" action ="register.php">
        <?php
        //get the values from the form, using the POST method.
        $first_name = $_POST['first_name'];
        $last_name = $_POST['last_name'];
        $profession = $_POST['profession'];
        $gender = $_POST['gender'];
        $date_of_birth = $_POST['date_of_birth'];
        $country_of_residence = $_POST['country_of_residence'];
        $email = $_POST['first_name'];
        $username = $_POST['username'];
        $password = $_POST['password'];
        $query = "SELECT username FROM account WHERE username = '$username' ";
        $result = mysqli_query($link, $query) ;  
        $queryInsert = "INSERT INTO user (first_name,last_name,profession,gender,date_of_birth,country_of_residence,email,username,password)" .
        "VALUES ('$first_name', '$last_name', '$profession', '$gender', '$date_of_birth', '$country_of_residence', '$email', '$username', '$password')";
        //echo $queryInsert;
        //echo $queryInsert;
        $resultInsert = mysqli_query($link,$queryInsert); 
        header('Location: login.php');
        echo "<h3>The following user has been successfully added:  </h3>";
      ?>
    Click <a href="admin.php"> here </a> to go back to the home page.
</body>
</html>

永远坚持该错误消息。无法找出我的连接或代码出错的地方。有人介意帮我吗?真的想不出我的错误在哪里。根本无法破译是连接还是代码问题。

您已在代码中添加了此行。 标头("位置:登录.php");

这意味着页面将重定向到登录.php。如果您将上面的页面命名为登录名.php则形成了一个重定向循环(再次重定向到同一页面)。因此,浏览器无法呈现该页面。