The question I am asking has been asked here but was asked pretty badly and resulted in the problem not being resolved. this koneksi.php
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "zou";
$con = mysqli_connect($host, $user, $pass, $db);
if (mysqli_connect_errno()){
echo "Koneksi gagal: " . mysqli_connect_error();
}
?>
this is my cek_login.php
session_start();
// menghubungkan php dengan koneksi database
include 'koneksi.php';
// menangkap data yang dikirim dari form login
$username = $_POST['username'];
$password = md5($_POST['password']);
// menyeleksi data user dengan username dan password yang sesuai
$query = mysqli_query($con, "SELECT * FROM user WHERE username='$username' AND password='$password'");
$data = mysqli_fetch_array($query);
$jml = mysqli_num_rows($query);
// cek apakah username dan password di temukan pada database
if($jml > 0){
$data = mysqli_fetch_assoc($login);
// cek jika user login sebagai admin
if($data['level']=="admin"){
// buat session login dan username
$_SESSION['username'] = $username;
$_SESSION['level'] = "admin";
// alihkan ke halaman dashboard admin
header("location:dashboard.php");
}else{
// alihkan ke halaman login kembali
header("location:index.php?pesan=gagal");
}
}
why i can't defined the username? the detail in $username can't call.
What is the meaning of these error messages?
how do i fix them?