Daftar dan Belajar Sekarang!

Tidak bisa login

foto randishady25
12 Kontribusi 1 Coto
2 bulan yang lalu
login.php
<html>
	<head>
		<title>Halaman Login</title>
		<link rel="stylesheet" type="text/css" href="css/login.css">
	</head>
	<body>
		<div class="login-box">
			<img src="image/login.jpg" class="avatar">
			<form action="proseslogin.php" method="POST">
				<h1>Masuk</h1>
				<input name="username" type="text" placeholder="Masukan Nama Pengguna Disini">
				<input name="password" type="password" placeholder="Masukan Kata Sandi Disini">
				<input name="login" value="Login" type="submit">				
				<input name="reset" value="Batal" type="reset">
				<p>Belum Punya akun ?</P><a href="daftar.php"><b>DAFTAR</b></a>
			</form>
		</div>
	</body>
</html>
proseslogin.php
<?php
include "koneksi.php";
 
if(isset($_POST['login'])){
	 
     $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_array();
		  
				$_SESSION['login'] = true;
          $_SESSION['username'] = $row['username'];
          $_SESSION['nama'] = $row['nama'];
          $_SESSION['level'] = $row['level'];
          $_SESSION['id_user'] = $row['id_user'];
          header("location:halamanutama.php");
				echo "<script>alert('Selamat Datang...');location.href='halamanutama.php'</script>";
    }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>";
}

?>
tabel user di database https://i.imgur.com/hSnKA6W.png halamanutama.php
<?php
include "koneksi.php";
$nama = $_SESSION['nama'];
?>
<html>
	<head>
		<title>Tampilan Utama</title>
		<link rel="stylesheet" type="text/css" href="css/index.css">
	</head>
<body>
	<div id="wrapper">
		<header>
			<P>Selamat datang, <?php echo $_SESSION["nama"]?></P>
		</header>
	<?php
	include "header.php";
	?>
	<div id="content">
	</div>
	
	
	
	<div id="footer">
	</div>
	</div>
</body>
gan tolong bantuannya gak bisa masuk ke halaman utama nih pdhl username sama passnya udh bener

Jawaban
foto verified logo Nandar
608 Kontribusi 179 Coto
2 bulan yang lalu
password nya di encrypt tidak? kalau y salah query cari nya

Login untuk tulis komentar


foto Obby14
107 Kontribusi 7 Coto
2 bulan yang lalu
kasih tau ss error nya kaya gimana biar bisa tau masalah nya.....


Login untuk diksusi di forum sekolah koding