warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given on line 8

1<?php 2 session_start(); 3 include_once 'koneksi.php'; 4 5 $username = $_POST['username']; 6 $password = $_POST['password']; 7 $query = mysqli_query($connect, "SELECT * FROM users WHERE username = '$username' AND password = '$password'"); 8 $bacadata = mysqli_fetch_array($query); 9 $db_id = $bacadata['username']; 10 $db_pass = $bacadata['password']; if ($username == $db_id && $password == $db_pass) { $_SESSION["userid"] = $userid; header("location:readpembeli.php"); } else if ($username == "" || $password == "") { echo 'Nama userid dan Kata Sandi tidak boleh kosong'; } else{ echo "maaf ID userid dan Password tidak sesuai. Harap coba lagi."; } ?>
avatar Jihadazhar12

@Jihadazhar12

15 Kontribusi 0 Poin


Jawaban

$query = mysqli_query($connect, "SELECT * FROM users WHERE username = '$username' AND password = '$password'");
pastikan query ini dapat berjalan dengan baik
avatar driyan

@driyan

190 Kontribusi 108 Poin

  • thanks dude, salah masukan harusnya user bukan users hahah - @Jihadazhar12


Login untuk gabung berdiskusi