I've hosted my website on 000webhost. It was working fine locally with no errors at all. Once I've hosted there, this error has arised on the contact page:
Warning: session_start(): Cannot start session when headers already sent in ..
my code is as follow:
<!DOCTYPE html>
<html lang="en">
<?php
session_start();
require_once('config.php'); //the required page has no session_start() inside it
if (empty($_SESSION['user'])) {
if (!empty($_COOKIE['email']) && !empty($_COOKIE['name']) && !empty($_COOKIE['role']) && !empty($_COOKIE['id'])) { //remember me was selected at last log in
if ($_COOKIE['role'] != 'customer')
redirect_page('../admin_home.php?status=not_auth');
$_SESSION['user']['email'] = $_COOKIE['email'];
$_SESSION['user']['name'] = $_COOKIE['name'];
$_SESSION['user']['role'] = $_COOKIE['role'];
$_SESSION['user']['id'] = $_COOKIE['id'];
$welcome = true;
} else {
$welcome = false;
}
} else {
if ($_SESSION['user']['role'] == 'admin') {
redirect_page('../admin_home.php?status=not_auth');
} else {
$welcome = true;
}
}
?>
<head>
<title>Sure Wheels</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- some styling and links -->
Would anyone please tell me whats wrong with my code?
TIA