<? include("si_confi.php"); ?>
<? include("ad_head.php");?>  <div class="container">
  <? include("mn_option.php");?>
<?
if(isset($_REQUEST['submit']))
	{
		$oldpassword = $_REQUEST['oldpassword'];
		$newpassword = $_REQUEST['newpassword'];
		$confirmpassword = $_REQUEST['confirmpassword'];
		
		$select_old_password=mysql_query("select count(*) as num from `hr_master_log` where `password`='$oldpassword' and `username`='$loginusername'");
		$fetch_old_password=mysql_fetch_array($select_old_password);
		$confirm_old_pass=$fetch_old_password['num'];
		if($confirm_old_pass=='1')
		{
			if($newpassword==$confirmpassword)
			{
				$update_news_password=mysql_query("update `hr_master_log` set `password`='$confirmpassword' where `username`='$loginusername'");
				?><script>window.location="ch_to_pass.php?change=success";</script><?
			}else{
				?><script>window.location="ch_to_pass.php?confirm=wrong";</script><?
			}}else{
			?><script>window.location="ch_to_pass.php?old=wrong";</script><? } } ?>
 
 

 <? if($_REQUEST['confirm']=='wrong'){ ?>
  <div class="warning" style="width:92%;margin:0 auto;margin-top:9px;">Invalid Confirm Password.</div><? } ?>
  
   <? if($_REQUEST['old']=='wrong'){ ?>
  <div class="warning" style="width:92%;margin:0 auto;margin-top:9px;">Invalid Old Password. </div><? } ?>
  
   <? if($_REQUEST['change']=='success'){ ?>
  <div class="success" style="width:92%;margin:0 auto;margin-top:9px;">New Password Changed successfully.</div><? } ?>
  
  

   <div style="border:groove;margin-top:10px;border-width:thin;padding:20px;border-radius:4px;border-color:#cccccc;box-shadow: 10px 9px 90px #000;">
   <h2>Change Password</h2>
        <form method="post"  id="chgpass" class="mdsform">
<script src="prototype.js" type="text/javascript"></script>
<script src="validation.js" type="text/javascript"></script>
<table cellpadding="8" id="add_employee">
<tr>
<td>Old Password</td>
<td><input  name="oldpassword" id="oldpassword" type="password"  class="required"  size="36" ></td>
</tr>
<tr>
<td>New Password</td>
<td><input name="confirmpassword" id="confirmpassword" type="password" class="required" size="36" ></td>
</tr>
<tr>
<td>Confirm Password</td>
<td><input name="newpassword" id="newpassword" type="password" class="required" size="36" ></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input  id="Submit" type="submit" value="Update" name="submit" /></td>
</tr>
</table>
</form>
<script type="text/javascript">
						function formCallback(result, form) 
						{
							window.status = "valiation callback for form '" + form.id + "': result = " + result;
						}
						var valid = new Validation('chgpass', {immediate : true, onFormValidate : formCallback});
					</script>
  </div>
</div><!-- container -->
  </body>
</html>