Daftar dan Belajar Sekarang!

Undefined index: level in index.php on line 4 Undefined variable: level_a in index.php on line 16

foto randishady25
12 Kontribusi 1 Coto
3 bulan yang lalu
proseslogin.php
<?php
session_start();
include "koneksi.php";
 
if(isset($_POST['username']) && ($_POST['password'])){
     $username = mysqli_real_escape_string($_POST['username']);
     $password = mysqli_real_escape_string($_POST['password']);
     $sql = "select * from user where username = '$username' AND password = '$password'";
     $result = $conn->query($sql) or die('Terjadi Kesalahan : '.$conn->mysqli_error);
   
    if ($result->mysqli_num_rows > 0){
          $row = $result->mysqli_fetch_assoc();
 
          $_SESSION['username'] = $row['username'];
          $_SESSION['nama'] = $row['nama'];
          $_SESSION['level'] = $row['administrator' or 'manajemen' or 'peminjam'];
          $_SESSION['id_user'] = $row['id_user'];
          header("location:index.php");
          $_SESSION['pesan'] = '<p><div class="alert alert-success">Selamat datang <b>'.$_SESSION['nama'].'</b></div></p>';
 
    }else{
          echo "<script>alert('Maaf, username atau password salah..');location.href='login.php'</script>";
    }
}else{
     echo "<script>alert('Maaf, username atau password salah..');location.href='login.php'</script>";
}
$level_a=$_SESSION['level'] == 'administrator';
$level_m=$_SESSION['level'] == 'manajemen';
$level_p=$_SESSION['level'] == 'peminjam';
?>
index.php
<?php
include "koneksi.php";
session_start();
$level=$_SESSION['level'];
if($level=='administrator' or 'manajemen' or 'peminjam'){
 
isset ($_GET['m']) ? $m = $_GET['m'] : $m = 'home';
?>
<html>
	<head>
	<title>Tampilan Utama</title>
	<link rel="stylesheet" type="text/css" href="css/index.css">
	</head>
	<body>
	<?php
	if($level_a){?>
		<div id="wrapper">
		<div id="header">
		<br>
		<P>Selamat datang, <?php echo $_SESSION["nama"]?></P>
		<br>
		<a href="admin.php" class="tombol">Home</a>
		<a href="pinjamadmin1.php" class="tombol">Entri Peminjaman Barang</a>
		<a href="" class="tombol">Entri Data Barang</a>
		<a href="" class="tombol">Tentang</a>
		<a href="logout.php" class="tombol">Keluar</a>
		</div>';
	<?php
	}else if($level_m){ ?>
		<div id="wrapper">
		<div id="header">
		<br>
		<P>Selamat datang, <?php echo $_SESSION["nama"]?></P>
		<br>
		<a href="manajemen.php" class="tombol">Home</a>
		<a href="" class="tombol">Entri Data Barang</a>
		<a href="" class="tombol">Laporan</a>
		<a href="" class="tombol">Tentang</a>
		<a href="logout.php" class="tombol">Keluar</a>
		</div>
	<?php
	}else if($level_p){ ?> 
		<div id="wrapper">
		<div id="header">
		<br>
		<P>Selamat datang, <?php echo $_SESSION["nama"]?></P>
		<br>
		<a href="peminjam.php" class="tombol">Home</a>
		<a href="" class="tombol">Entri Peminjaman Barang</a>
		<a href="" class="tombol">Tentang</a>
		<a href="logout.php" class="tombol">Keluar</a>
		</div>
	<?php
	}
}?>
	<div id="content">
	</div>
	
	
	
	<div id="footer">
	</div>
</body>
salahnya dimna ? tolong bantuannya

Jawaban
foto stivnz
318 Kontribusi 97 Coto
3 bulan yang lalu
ada } yang tidak terpasang atau ; yang kelupaan


Login untuk diksusi di forum sekolah koding