I have some warning if login successful.
this is an error
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\PSI\index.php:25) in C:\xampp\htdocs\PSI\proseslogin.php on line 32
There are my sources.
proseslogin.php
if ($password == $data['password'])
{
// menyimpan username dan level ke dalam session
$_SESSION['user_akses'] = $data['user_akses'];
$_SESSION['username'] = $data['username'];
include "index.php";
}
else echo "<h1>Login Failure</h1>";
header("Refresh:2; url=login.php");
?>
This is an error
line 32 => header("Refresh:2; url=login.php");
That header for failure login which can refresh about 2 sec and go back to logion session in login.php
FYI : I use PHP 7
Everything is simple - you can't send headers AFTER you output anything on the client side (no matter if it's text, html or just a blank space). Try to use header before outputting the content, and you'll see your error will be gone.
Try this:
if ($password == $data['password']) {
// menyimpan username dan level ke dalam session
$_SESSION['user_akses'] = $data['user_akses'];
$_SESSION['username'] = $data['username'];
include 'index.php';
}else {
//headers before the content
header('Refresh:2; url=login.php');
//and then content here
echo '<h1>Login Failure</h1>';
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.