<?php
include("../../inc/koneksi.php");
require('../../inc/password.php'); 

$id = mysql_real_escape_string($_POST['id']);
$pass = mysql_real_escape_string($_POST['password']);

//cek user
$login="SELECT * FROM petugas WHERE id_petugas='$id'";
$cek=mysql_query($login) or die(mysql_error());
$isi=mysql_fetch_array($cek);

$wrong = "";
//cek;
if(password_verify($pass, $isi['password'])) 
{
	session_start();
	$_SESSION['id_petugas'] = $isi['id_petugas'];
	$_SESSION['nama'] = $isi['nama'];
	$_SESSION['telp'] = $isi['telp'];

	$id_petugas = $_SESSION['id_petugas'];
	$nama = $_SESSION['nama'];
	$telp = $_SESSION['telp'];
	
	echo "<meta http-equiv='refresh' content='0; url=../index.php'>";
}
else
{
	$wrong = "salah";
}

if($wrong == "")
	{
		echo "<meta http-equiv='refresh' content='0; url=../index.php'>";
	}
	else
	{
		echo "<script language=\"javascript\">
			window.location='../login.php?ket=$wrong';
		</script>";	
	}
		
?>