<?php
/* User login process, checks if user exists and password is correct */
// Escape email to protect against SQL injections
$email = $mysqli->escape_string($_POST['email']);
$result = $mysqli->query("SELECT * FROM users WHERE email='$email'");
if ( $result->num_rows == 0 ){ // User doesn't exist
header("location: error.php");
$_SESSION['message'] = "User with that email doesn't exist!";
}
Warning: Cannot modify header information
- headers already sent by
(output started at /some-server/Pages/index.php:10)
in /some-server/Pages/login.php on line 9
有人可以帮我解决这个问题吗? 谢谢
这是代码中最热门的,抱歉不提前添加:
<?php
/* Main page with two forms: sign up and log in */
require 'db.php';
session_start();
?>
<!DOCTYPE html>
<html>
<head>
<title>Sign-Up/Login Form</title>
<?php include 'css/css.html'; ?>
</head>
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
if (isset($_POST['login'])) { //user logging in
require 'login.php';
}
elseif (isset($_POST['register'])) { //user registering
require 'register.php';
}
}
?>
答案 0 :(得分:0)
当您收到此错误时,表示您已经回显/打印了某些内容,因此无法发送标题。
PHP有用地告诉你headers already sent by…
。如果您检查这是指的代码,您应该能够轻松找到您回复某些内容的位置。
通常是:
print_r
,var_dump
等)<?php
前两个通常很明显;第三个可能有点棘手!
如果您发布更多代码,我将很乐意为此答案添加细节。