When I try to use the code below:
<?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!";
}
I get the following error:
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
Can someone please help me solve this issue? Thank You
//Update//
This is the rrest of the code, sorry for not adding this earlier:
<?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';
}
}
?>