Tolong Bantu saya Kaka :"(

Notice: Undefined variable: qu in /storage/ssd3/922/15228922/public_html/koneksi.php on line 4 Warning: mysqli_connect(): (HY000/2005): Unknown MySQL server host 'https://databases.000webhost.com/' (1) in /storage/ssd3/922/15228922/public_html/koneksi.php on line 7 Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /storage/ssd3/922/15228922/public_html/koneksi.php on line 7
Saya di local bisa tapi saat di hosting di hosting gratis ko kaya gitu ya ka ?

Berikut kode saya pak 

<?php

//panggil database
include "koneksi.php";

$pass = md5($_POST['password']);
$username = mysqli_escape_string($koneksi, $_POST['username']);
$password = mysqli_escape_string($koneksi, $pass);
$level = mysqli_escape_string($koneksi, $_POST['level']);

//cek username, terdaftar atau tidak

$cek_user = mysqli_query($koneksi, "SELECT * FROM tuser WHERE username = '$username' and level = '$level' ");
$user_valid = mysqli_fetch_array($cek_user);
//uji jika username terdaftar

if($user_valid){
    //jika username terdaftar
    //cek password sesuai atau tidak
    if($password == $user_valid['password']){
        //jika password sesuai
        //buat seasion
        session_start();
        $_SESSION['username'] = $user_valid['username'];
        $_SESSION['nama_lengkap'] = $user_valid['nama_lengkap'];
        $_SESSION['level'] = $user_valid['level'];

        //uji level user
        if($level == "Admin"){
            header('location:home_Admin.php');
        } elseif ($level == "User"){
            header('location:home_User.php');
        }  

    } else{
        echo "<script>alert('Mohon maaf login gagal, Cek Password Anda!!');document.location='index.php'</script>";
    }

} else{
    echo "<script>alert('Mohon maaf login gagal, Cek Username Anda !!');document.location='index.php'</script>";
}



?>

File Koneksinya ka ::::

<?php
$server = "localhost";
$user = "root";
$password = "";
$database = "dblatihan";

$koneksi = mysqli_connect($server, $user, $password, $database) or die(mysqli_error($koneksi));

?>
avatar arifagustin

@arifagustin

3 Kontribusi 0 Poin

  • baca aturan main, ganti judul kamu lebih baik - @hilmanski


Jawaban

Belum ada Jawaban, jadi yang pertama

Login untuk gabung berdiskusi