Daftar dan Belajar Sekarang!

Fatal error: uncaught error: call to undefined method mysqli::mysqli_query()

foto randishady25
12 Kontribusi 1 Coto
1 bulan yang lalu
<?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->mysqli_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';
?>
pagi gan maaf mau tanya ini salahnya dimana yah?

Tag: html php

✔ Forum ini sudah terjawab


Jawaban
foto stefanuspn
249 Kontribusi 68 Coto
1 bulan yang lalu
<?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';
?>
answered icon
foto stefanuspn
249 Kontribusi 68 Coto
1 bulan yang lalu
<?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';
?>


Login untuk diksusi di forum sekolah koding