PHP Cannot modify header - already sent
Scris: Lun Oct 29, 2018
Am reusit sa rezolv si logarea pe site. Acum citeste parola.
Inca o intrebare totusi. Dupa ce ma loghez nu mai poate sa afiseze header-ul cum ca esti logat direct.
Ma loghez, totul bine, insa nu apare header-ul pana nu dau refresh la pagina.Nu cred ca am gresit ceva la parola din moment ce autentificarea se face.
In error_log imi zice doar ca nu a putut sa modifice informatia din header si atat
La login m-am folosit tot de openssl_encrypt ca sa imi citeasca parola direct criptata din baza de date.Functioneaza doar ca nu poate sa modifice header-ul.Logarea pe site se face si nu inteleg de ce...
Inca o intrebare totusi. Dupa ce ma loghez nu mai poate sa afiseze header-ul cum ca esti logat direct.
Ma loghez, totul bine, insa nu apare header-ul pana nu dau refresh la pagina.Nu cred ca am gresit ceva la parola din moment ce autentificarea se face.
In error_log imi zice doar ca nu a putut sa modifice informatia din header si atat
Cod: SelectaĊ£i tot
[29-Oct-2018 14:34:09 Europe/Bucharest] PHP Warning: Cannot modify header information - headers already sent by (output started at /public_html/index.php:69) in /public_html/inc/Config.class.php on line 75
Cod: SelectaĊ£i tot
public static function setHeader() {
if(isset($_SESSION['user_web']))
{
echo '
<div class="guestpanel" style="margin-top: 16px">
<div style = "font-size: 18px;">
<div class="dropdown">
<div class = "user_name_cls">Welcome back '.Config::getData('users','username',$_SESSION['user_web']).'!</div>
<i class="fa fa-caret-down" style="font-size:11px"></i>
<div class="dropdown-content">
<li class = "firstLi"><a href ="index.php">Acasa</a></li>
<li><a href ="../customer/usercp.php">Profile</a></li>
<li><a href="'.Config::$_PAGE_URL.'adm/logout.php">Log out</a></li>
</div>
</div>
</div>
</div>';
} else {
if(isset($_POST['submit_login']))
{
$password = $_POST['password'];
$key_enc = '1234';
$met_enc = 'aes128';
$iv = '16_characters_ok';
$pass_enc = openssl_encrypt($password, $met_enc, $key_enc, 0, $iv);
$q = Config::$g_con->prepare('SELECT * FROM `users` WHERE `username` = ? AND `password` = ?');
$q->execute(array($_POST['username'],$pass_enc));
if($q->rowCount())
{
while($row = $q->fetch(PDO::FETCH_OBJ))
{
$_SESSION['user_web'] = $row->ID;
header('location: '.Config::$_PAGE_URL.'' );
}
} else {
echo '<strong><font color="red">Incorrect username or password!</font></strong><br><br>';
}
}
else
{
echo '<div class="guestpanel">
<form action="" method="post">
<input type="text" placeholder = "Username" name="username" value="" class="form_sml" required/>
<input type="password" placeholder = "Password" name="password" value="" class="form_sml" required/>
<button type="submit" name="submit_login" value="Login" class="button_submit button_sml button_black float_left">Login
</button>
<a href="'.Config::$_PAGE_URL.'adm/register.php" class="button_sml button_blue tip"
title="Sign up with to be a part of our quickly growing community">Register</a>
</form>
</div>';
}
}
}