I am very new to PHP. Coding my first website.
index.php
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<form action="authenticate.php" method="post">
//form inputs
</form>
</body>
</html>
The form calls authenticate.php:
<?php
session_start();
//Authenication work
//...
// line 43 here
if(!$authen){
include_once("index.php");
}
else{
header('Location: main.php');
exit();
}
?>
Whenever I run the website and login, as soon as i click on the submit button in the form, instead of being redirected to main.php
, I get redirected in the browser to authenticate.php
, and I see this :
Text in image:
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/projet/authenticate.php:1) in /var/www/html/projet/authenticate.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/projet/authenticate.php:1) in /var/www/html/projet/authenticate.php on line 51
My main.php
code (the page I was supposed to be redirected to instead):
<?php session_start(); ?>
<html>
<head>
...
Things I have tried so far:
- Making sure session_start() is at the beginning of every page
- Trimming EVERY POSSIBLE white space before
<?php
and after?>
I am getting desperate. Please note that the same website and files work locally on wampserver, but when i put them on a server this happened.
Am I missing something? Sorry I am completely new to PHP and I am learning.
Also questions:
- Do comments in PHP files count as empty spaces?
- Does Indentation in conditions in PHP files count as empty spaces?