I have received these errors:
[phpBB Debug] PHP Warning: in file [ROOT]/includes/session.php on line 1042: Cannot modify header information - headers already sent by (output started at /home4/ink/public_html/testpage.php:3)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/session.php on line 1042: Cannot modify header information - headers already sent by (output started at /home4/ink/public_html/testpage.php:3)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/session.php on line 1042: Cannot modify header information - headers already sent by (output started at /home4/ink/public_html/testpage.php:3)
I have searched for the following solutions: - Using a non-UTF file format - Using header(location 'www.example.com') - Clearing blank spaces before or after php tag - Putting the php session starts at the beginning of all files, and other areas
I am trying to provide a login area, utilizing the phpBB database for usernames and passwords. The following code works once you have visited the forums, but until then, it spits out the error above.
Here is the code.
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$user->session_begin();
$auth->acl($user->data);
$user->setup();
if($user->data['is_registered'])
{
echo "Hello " . $user->data['username']; //User is already logged in
echo "<br /> Last visit: " . $user->format_date($user->data['session_last_visit']);
}
else
{
echo '<form method="POST" action="./forum/ucp.php?mode=login">
<p>Username: <input type="text" name="username" size="40"><br />
Password: <input type="password" name="password" size="40"><br />
Remember Me?: <input type="checkbox" name="autologin"><br /><br /><br />
<input type="submit" value="Submit" name="login"></p>
</form>';
}?>
This code is used in the menu area of the site. The code above is found in an include, which is used across the entire site.
From my searching to figure out an answer, I feel the solution is going to involve putting parts of the code in a file before the rest of the site is called, so that the session can start first before anything else. If so, I would love some insight on how to go about this, and if not, then that would be why I have been unable to solve this!
I looked through all of the stack overflow question with this error, and I couldn't find a workable solution in any of them. Nor did phpBB's documentation assist in specifying more about this header issue.
If more info is needed, ask away!