I´ve read through about 10 similiar questions as mine, but couldn´t find a solution.
I created a simple forum based website on my students-domain on which it worked finde. I also created a webserver with my raspberry pi on which it also worked like a charme.
But know I moved to a public domain with the same php-version but now I keep running into this error:
Cannot modify header information - headers already sent by (output started at /home/site/public_html/forum/config.inc.php:1) in /home/site/public_html/forum/action_login.php on line 9
I checked whitespaces,
tried with exit(header(Location: "X"));
or header(Location: "X");exit;
and also used absolute pathes.
But nothing worked.
This is the file I´m getting stuck in:
<?php
session_start();
error_reporting(E_ALL & ~E_NOTICE);
require_once('config.inc.php');
$host = "http://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
if(((empty($_POST['username'])) || (empty($_POST['password']))) && (isset($_POST['Login'])))
{
header("Location: $host/index.php?error=2");exit;
}
else if(!preg_match("/^[a-zA-Z0-9äöüÄÖÜ-]*$/", $_POST['username']) && isset($_POST['Login']))
{
header("Location: $host/index.php?error=1");exit;
}
else
{
$logedin = $auth->login($_POST['username'], $_POST['password']);
$userId = $auth->getUserID($_POST['username']);
if($logedin)
{
$_SESSION['name'] = strtolower($_POST['username']);
$_SESSION['id'] = $userId;
}
header("Location: $host/startpage.php");exit;
}
if(isset($_POST['Logout']))
{
session_destroy();
header("Location: $host/index.php");exit;
}
So I submit the credentials from my login.php and then get stuck in my action_login.php, because the header() won´t redirect me.
Thanks for your help