On my PHP login system, every time I try to sign in as another user (or type random letters and hit sign in), I get:
Warning: Cannot modify header information - headers already sent by (output started at /home/lewisad2/public_html/login.php:13) in /home/lewisad2/public_html/login.php on line 20
I have searched the internet and can't seem to find a solution and have been stuck with this problem for a few hours now, please can someone help me.
The login.php code is below:
<?php
session_start();
include 'dbh.php';
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];
$sql = "SELECT * FROM user WHERE uid='$uid' AND pwd='$pwd'";
$result = mysqli_query($conn, $sql);
if(!$row = mysqli_fetch_assoc($result)) {
echo 'Username or Password incorrect.';
} else if(!$_SESSION['id']) {
$_SESSION['id'] = $row['id'];
$_SESSION['firstname'] = $row['firstname'];
} else {
echo 'You are already logged in!';
}
header("Location: index.php");