【问题标题】:The connection to the server was reset while thepage was loading php error页面加载 php 错误时重置与服务器的连接
【发布时间】:2016-01-30 07:12:37
【问题描述】:
<?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>

一直被该错误消息困扰。无法找出我的连接或代码哪里出了问题。有人介意帮助我吗?真的想不出我的错误在哪里。根本无法判断是连接问题还是代码问题。

【问题讨论】:

  • 它不是 include 'dbConnection.php'; 。将其更改为include('dbConnection.php');
  • 嗯,我做了相应的更改,但仍然有同样的错误
  • &lt;form method ="post" action ="register.php"&gt; 在那里做什么?与include 'dbConnection.php'; 一起分享您的完整代码。请。
  • 您遇到了什么错误?也请粘贴您的错误。

标签: php database mysqli


【解决方案1】:

您已在代码中添加了这一行。 header('位置:login.php');

这意味着页面将重定向到 login.php。如果您将上述页面命名为 login.php,那么就会形成一个重定向循环(再次重定向到同一页面)。因此浏览器无法呈现该页面。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-26
    • 1970-01-01
    • 1970-01-01
    • 2012-12-05
    • 2021-04-20
    • 2016-04-09
    • 1970-01-01
    相关资源
    最近更新 更多