<?php
session_start();
include ‘../conn/connection.php’;
if (!empty($_POST['txtUsername']) && !empty($_POST['txtPassword'])) {
$username = $_POST['txtUsername'];
$karakter = “D3PxK4IzP3Bz”;
$enkripsi = md5($karakter . $_POST['txtPassword']);
$qUser = “select nip,nama,username,password,level from tbl_pengguna where
username=’$username’ and password=’$enkripsi’”;
$rsUser = mysql_query($qUser);
$rUser = mysql_fetch_array($rsUser);
if ($rUser[2] == $username && $rUser[3] == $enkripsi) {
$_SESSION['id_acount'] = $rUser[0];
$_SESSION['name_acount'] = $rUser[1];
$_SESSION['username_acount'] = $rUser[2];
$_SESSION['password_acount'] = $rUser[3];
$_SESSION['level_acount'] = $rUser[4];
?>
<script lang=”javascript”>
alert(“Selamat, Anda berhasil login…”);
</script>
<?php
if ($_SESSION['level_acount'] == “Administrator”) {
?>
<script lang=”javascript”>
document.location = “../admin/index.php”;
</script>
<?php
}else{
?>
<script lang=”javascript”>
document.location = “../index.php”;
</script>
<?php
}
} else {
?>
<script lang=”javascript”>
alert(“Maaf, Login gagal!\nSilakan periksa username dan password anda…”);
document.location = “../index.php”;
</script>
<?php
}
}else{
?>
<script lang=”javascript”>
alert(“Maaf, Login gagal!\nSilakan masukan username dan password anda…”);
document.location = “../index.php”;
</script>
<?php
}
?>
No comments:
Post a Comment