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

$passlama = md5($_POST['pass_lama']);
$passbaru1 = md5($_POST['pass_baru1']);
$passbaru2 = md5($_POST['pass_baru2']);

$user = $_POST['user'];
$wrong = "";
//cari pass lama
$q = "SELECT password FROM admin WHERE username = '$user'";
$c = mysql_query($q);
$j = mysql_fetch_array($c);

if (empty($passlama) and empty($passbaru1) and empty($passbaru2))
{
	$wrong = "kosong";
}
else if ($passbaru1 !== $passbaru2)
{
	$wrong = "passbaru";
}

if ($passlama==$j[0])
{
		$update = "update admin set password='$passbaru1' where username = '$user'";
		$set = mysql_query($update) or die (mysql_error());
}
else
{
	$wrong = "passlama";
}
		
if($wrong == "")
	$url = "index.php?act=setting&ket=berhasil";
else
	$url = "index.php?act=setting&ket=$wrong";

echo "<script language=\"javascript\">
	window.location='../$url';
</script>";
?>