Postingan lainnya
index user pada session tidak terdifinisi
Mohon bantuannya gan,
Udah seharian nyari errornya dimana gan, tapi nggak dapat2
Notice: Undefined index: USER in C:\xampp\htdocs\lrn_blog\login.php on line 6
udah di session start di init.php
<?php
require_once "core/init.php";
$error= '';
if ($_SESSION['user']){
header('Location: index.php');
}else{
if (isset($_POST['submit'])) {
$nama = $_POST['nama'];
$pass = $_POST['password'];
if (!empty(trim($nama)) && !empty(trim($pass)) ) {
if (cek_data($nama, $pass)) {
$_SESSION['user'] = $nama;
header('Location: index.php');
return $nama;
}else{
$error = "ada masalah saat login!";
}
}else {
$error = "user dan password wajib diisi!";
}
}
require_once "view/header.php";
?>
<form action="#" method="post">
<label for="nama">Username</label> <br>
<input type="text" name="nama" placeholder = "masukkan username"><br><br>
<label for="konten">Password</label><br>
<input type="password" name="password" placeholder = "masukkan password">
<div class="error">
<?=$error?>
</div><br>
<input type="submit" name="submit" value="login">
</form>
<?php
require_once "view/footer.php";
}
?>
Terima kasih telah membantu
0
1 Jawaban:
Jawaban Terpilih
ane udah dapat jawabannya!
<pre> if (isset($_SESSION['user'])){ header('Location: index.php'); </pre>
ternyata ane lupa submit gan
0