<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-body">
	
	<div class="page-header">
			<h2>Ubah Password</h2>
			<ol class="breadcrumb">

				<li><a href="dashboard.php"><i class="fa fa-home"> Home</i></a></li>
				<li class="active"><i class="fa fa-key"> Ubah Password </i></li>
            </ol>
		</div>
<?php
if(isset($_POST['button']))
{
	if($_SESSION['jabatan']=='admin' or $_SESSION['jabatan']=='panitia'){
		$sc1=sprintf("Select * from user where id_user='%s' and password='%s'",$_SESSION['id_user'],md5($_POST['old_password']));
	
		$q1=mysql_query($sc1);
		$rc1=mysql_num_rows($q1);
		if($rc1==1)
		{
			$sc2=sprintf("Update user Set password='%s' Where id_user='%s'",md5($_POST['new_password']),$_SESSION['id_user']);
			$q2=mysql_query($sc2);
			if($q2)
			{
			?> <div class="panel-body">
				<div class="row">
				<div class="col-md-offset-2 col-md-8">
				<div class="alert alert-success  alert-dismissable">
				<button type="button" class="close" data-dismiss="alert">x</button>
				<center>Password Berhasil diubah</center>
				</div></div></div>
	 
				<?php
			}else{
			?> <div class="panel-body">
				<div class="row">
				<div class="col-md-offset-2 col-md-8">
				<div class="alert alert-danger  alert-dismissable">
				<button type="button" class="close" data-dismiss="alert">x</button>
				<center>Terjadi Kesalahan</center>
				</div></div></div>
	 
				<?php
			}
		}else{
			?> <div class="panel-body">
				<div class="row">
				<div class="col-md-offset-2 col-md-8">
				<div class="alert alert-danger  alert-dismissable">
				<button type="button" class="close" data-dismiss="alert">x</button>
				<center>Verifikasi Password Lama Salah</center>
				</div></div></div>
	 
				<?php
		}
	}
	

	if($_SESSION['jabatan']=='perusahaan'){
		$sc1=sprintf("Select * from perusahaan where id_perusahaan='%s' and password='%s'",$_SESSION['id_perusahaan'],md5($_POST['old_password']));
	
		$q1=mysql_query($sc1);
		$rc1=mysql_num_rows($q1);
		if($rc1==1)
		{
			$sc2=sprintf("Update perusahaan Set password='%s' Where id_perusahaan='%s'",md5($_POST['new_password']),$_SESSION['id_perusahaan']);
			$q2=mysql_query($sc2);
			if($q2)
			{
			?> <div class="panel-body">
				<div class="row">
				<div class="col-md-offset-2 col-md-8">
				<div class="alert alert-success  alert-dismissable">
				<button type="button" class="close" data-dismiss="alert">x</button>
				<center>Password Berhasil diubah</center>
				</div></div></div>
	 
				<?php
			}else{
			?> <div class="panel-body">
				<div class="row">
				<div class="col-md-offset-2 col-md-8">
				<div class="alert alert-danger  alert-dismissable">
				<button type="button" class="close" data-dismiss="alert">x</button>
				<center>Terjadi Kesalahan</center>
				</div></div></div>
	 
				<?php
			}
		}else{
			?> <div class="panel-body">
				<div class="row">
				<div class="col-md-offset-2 col-md-8">
				<div class="alert alert-danger  alert-dismissable">
				<button type="button" class="close" data-dismiss="alert">x</button>
				<center>Verifikasi Password Lama Salah</center>
				</div></div></div>
	 
				<?php
		}
	}

}
?>


<form class="form-horizontal"  method="post" action="" id="pass" enctype="multipart/form-data">

    <div class="form-group">
    <label for="password" class="col-xs-4 control-label">Password Lama</label>
    <div class="col-xs-4">
      <input type="password" class="form-control" id="password" name="old_password" placeholder="**********" required>
    </div>
  </div>
   <div class="form-group">
    <label for="password" class="col-xs-4 control-label">Password Baru</label>
    <div class="col-xs-4">
      <input type="password" class="form-control" id="password" name="new_password" placeholder="**********" required>
    </div>
 </div>
 <div class="form-group">
    <label for="konfirmasi_password" class="col-xs-4 control-label">Konfirmasi Password Baru</label>
    <div class="col-xs-4">
      <input type="password" class="form-control" id="konfirmasi_password" name="konfirmasi_password" placeholder="**********" required>
    </div>
 </div>
	   <div class="form-group">
      <div class="col-md-6 col-md-offset-4">
         <button name="button" id="button" type="submit" class="btn btn-primary">Update</button>
	  </button>
      </div>
   </div>
</form>

</div>
</div>
   </div>