5
Feb
2014

Listing Cek Login

/
0 Comments
Berikut adalah contoh listing Cek Login Untuk Admin :

<?php
include "koneksi.php";     *sesuaikan dengan nama file koneksi anda 
$userName = $_POST[username]; *nama [username] sesuaikan dengan label name pada file Login
$passWord = $_POST[password]; *nama [password] sesuaikan dengan label name pada file Login

$sql  = mysql_query("SELECT * FROM tuser WHERE Username = '$userName' AND Password = '$passWord' AND Level = '1'");
$ketemu = mysql_num_rows($sql);
$data = mysql_fetch_array($sql);



if (empty($userName) || empty($passWord)){
echo "<script>alert('Anda belum memasukkan username atau password'); window.location = 'index.php'</script>";
}
elseif ($level == '++'){
echo "<script>alert('Anda belum memilih level user'); window.location = 'index.php'</script>";
}
else{
if ($ketemu > 0){
$date = date('Y-m-d H:i:s');
mysql_query("UPDATE tuser SET LastLogin = '$date' WHERE IdUser = '$data[IdUser]'");
session_start();
session_register("IdUser");
session_register("Username");
session_register("Password");

$_SESSION[IdUser]  = $data[IdUser];
$_SESSION[Username] = $data[Username];
$_SESSION[Password] = $data[Password];

header('location: index.php'); * sesuaikan dengan nama file anda
}
else{
echo "<script>alert('Maaf Anda Tidak Memiliki Hak Akses'); window.location = 'index.php'</script>";
}
}
?>

Selamat Mencoba...
Bila ada kesulitan silahkan jangan ragu bertanya.


You may also like

No comments:

.

.