<?
session_start();
$brcode=$_SESSION['brcode'];
$user=$_SESSION['user'];
$yf=$_REQUEST['yf'];
$mf=$_REQUEST['mf'];
$df=$_REQUEST['df'];
include("opendb.php");

$result=mysqli_query($db,"select * from bruser where username='$user'") or die(mysqli_error());
$row=mysqli_fetch_array($result);
if($sub)
{
  if($oldp==$row[pswd] && $newp1 == $newp2 && $newp1!=$row[pswd] )
  {
$dt=$yf.'-'.$mf.'-'.$df;
    mysqli_query($db,"update bruser set pswd='$newp2',passdate='$dt' where username='$user'") or die(mysqli_error());
     print "<script> alert('Password has been changed.  Login again')</script>";
    include("logout.php");
     return;
  }
  else
   {
      print "<body bgcolor=silver><center><font color=red face=verdana size=2>
   <script> alert('Invalid Password') </script> ";
    include("logout.php");
      return;
  }
}



if(strlen($user)>0)
{
/* $user=$uname;
 print "<font face=verdana size=2 color=green>You are logged in as $user </font>";
*/
 chp();
}
else
{
 print "<script>alert('Invalid Login'); ";
 print "parent.document.location='index.html' </script>";
 return;
}
function chp()
{
?>
<style>
BODY,td{font-family:verdana; font-size:14;color:black}
</style>
<body bgcolor='#EBF0DB'>
<center> <br><br><br>
<B>CHANGE PASSWORD</B>
<br>
<form action="chp.php" method='post' >
<table border=1>
<tr><td>Enter old password</td><td><input type=password name=oldp></td></tr>
<tr><td>Enter new password</td><td><input type=password name=newp1></td></tr>
<tr><td>Confirm new password</td><td><input type=password name=newp2></td></tr>
<td>
Date </td><td>dd<input type=text name='df' size=2 readonly value='<?print date('d',time())?>'>
	mm<input type=text name='mf' size=2 readonly value='<?print date('m',time())?>'>
	yy<input type=text name='yf' size=4 readonly value='<?print date('Y',time())?>'>
 </td></tr>
<tr><td colspan=2 align=center><input type=SUBMIT name='sub' value='Change'>
<input type=button value='Cancel' onClick=document.location='blank.html'></td></tr>
</FORM>
<?
}
?>


