I am having an issue I cannot figure out. Been looking at it for 3 days now and I don't see anything wrong, maybe you can help. When I run the script, the form comes up and works well, when I submit it I get the following PHP error message:
header() comes after the session_start() but it's still telling me there is an issue. The include files all work and have no spaces or echo commands, they are used in another part of the site and work fine. Here is the code:
<?php include_once('../includes/connectvars.php');?>
<?php include_once('../functions/globalFunctions.php');?>
<?php
$webID = '';
$password = '';
$sendForm = '';
// * Form Processing *
if(isset($_POST['username'], $_POST['password'])){
$webID = $_POST['username'];
$password = $_POST['password'];
// * Validate login *
if(validateLoginAdmin($webID, $password, $conn) == false){
$sendForm = false;
}else{$sendForm = true;}
// * Good to go? Start Session *
if($sendForm == true){
//include_once('startSessionAdmin.php');
session_start();
$query = "SELECT * FROM adminlogin WHERE adminuser = '$webID' limit 1";
$result = mysqli_query($conn, $query);
$row = $result->fetch_assoc();
$_SESSION['firstName'] = $row['firstName'];
$_SESSION['lastName'] = $row['lastName'];
$_SESSION['login'] = 1;
$_SESSION['admin'] = 2;
$_SESSION['username'] = $webID;
header('Location:admin_landing.php');
exit();
}}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Login</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
<link rel="stylesheet" href="../css/login.css">
</head>
<body>
<div class="login">
<h1>Enrichment Week Admin Login</h1>
<form action="index.php" method="post">
<label for="username">
<i class="fas fa-user"></i>
</label>
<input type="text" name="username" placeholder="Username" id="username" required>
<label for="password">
<i class="fas fa-lock"></i>
</label>
<input type="password" name="password" placeholder="Password" id="password" required>
<input type="submit" value="Login">
</form>
</div>
</body>
</html>
What am I missing?