<?php
if(isset($_POST["Login"])){
$usr=$_POST["user"];
$pas=$_POST["pass"];
$ada1=cekAda($usr,"or");
$ada2=cekAda($usr,"'");
if($ada1>0){
session_destroy();
echo "<script>alert('Otentikasi Login GAGAL \'Cuy!,Silakan cek data Anda kembali...');
document.location.href='?mnu=login';</script>";
}
else if($ada2>0){
session_destroy();
echo "<script>alert('Otentikasi Login GAGAL \'Bray!,Silakan cek data Anda kembali...');
document.location.href='?mnu=login';</script>";
}
else{
$sql1="select * from `$tbadmin` where `username`='$usr' and `password`='$pas' and `status`='Aktif'";
if(getJum($conn,$sql1)>0){
$d=getField($conn,$sql1);
$kode=$d["id_admin"];
$nama=$d["nama_admin"];
$level=$d["level"];
$_SESSION["cid"]=$kode;
$_SESSION["cnama"]=$nama;
$_SESSION["cstatus"]="$level";
echo "<script>alert('Otentikasi ".$_SESSION["cstatus"]." ".$_SESSION["cnama"]." (".$_SESSION["cid"].") berhasil Login!');
document.location.href='index.php?mnu=home';</script>";
}
else{
session_destroy();
echo "<script>alert('Otentikasi Login GAGAL !,Silakan cek data Anda kembali...');
document.location.href='index.php?mnu=login';</script>";
}
}
}
function cekAda($x,$cari){
$ada=0;
if(strstr($x,$cari)){$ada=1;}
return $ada;
}
function cekadaString($kode,$cari){
$str=strstr($kode,$cari);
$ada=0;
if(strlen($str)==strlen($kode)){
$ada=1;
}
return $ada;
}
?>
Tidak ada komentar:
Posting Komentar