<? require_once "include/application.php"; 
if(!$_SESSION["egoUser"])header('Location: index.php');



if($btnUpdate){
	$sql = "select * from user where id='".$_SESSION["egoUser"]."' and pwd='".md5($oldpwd)."'";
	$result =mysql_query($sql)or die(mysql_error());
	if(mysql_num_rows($result) >0){
		$sql="update user set pwd='".md5($newpwd)."' where id='".$_SESSION["egoUser"]."'";
		@mysql_query($sql) or die(mysql_error());
		$action_msg="Password had been change.";		
	}else $action_msg="Invalid old password.";
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="sddm.css" >
<script src="include/validation.js" type="text/javascript"></script>
<title><? echo TITLE?></title>
</head>
<body>

<table width="1024" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#f1efd8">
  <tr>
    <td  colspan="2" align="center"><? require_once "include/header.php"; ?></td>
  </tr>
  <tr>
    <td colspan="2" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td width="185" valign="top" bgcolor="e6f3f9">
	
<? require_once "include/columnLeft.php"; ?>	</td>
    <td width="834" valign="top">
	<form name="mainform" method="post" action="<?=$PHP_SELF ?>"  ONSUBMIT="return ValidateChgPwd(this)">
	  <table width="700" height="250" border="0" align="center" cellpadding="0" cellspacing="0">
      
      <tr>
        <td><img src="images/border/03.gif" width="10" height="9" alt="" /></td>
        <td><img src="images/border/04.gif" width="678" height="9" alt="" /></td>
        <td><img src="images/border/05.gif" width="14" height="9" alt="" /></td>
        <td rowspan="3">&nbsp;</td>
      </tr>
      <tr>
        <td><img src="images/border/07.gif" width="10" height="250" alt="" /></td>
        <td valign="top"><table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr>
            <td height="30" colspan="2" class="TitleH3">Change Password </td>
          </tr>
          <tr>
            <td height="1" colspan="2" bgcolor="#B8ED83"></td>
          </tr>
          <tr>
            <td colspan="2" ><? echo "<div class='Msg'>$action_msg</div>" ?>&nbsp;</td>
          </tr>
          <tr>
            <td class="TextH1">Username</td>
            <td height="30"><? echo $_SESSION["egoUser"] ?></td>
          </tr>
          <tr>
            <td width="29%" class="TextH1">Old Password <span class="require">*</span></td>
            <td width="71%" height="30"><input name="oldpwd"  type="password" value="<? echo $oldpwd ?>" size="30" /></td>
          </tr>
          <tr>
            <td height="30" class="TextH1">New Password <span class="require">*</span></td>
            <td height="30" class="TextH1"><input name="newpwd"  type="password" value="<? echo $newpwd ?>" size="30" />
                <span class="subItem">(Minimum 6 characters)</span></td>
          </tr>
          <tr>
            <td height="30" class="TextH1">Confirm New Password <span class="require">*</span></td>
            <td height="30" class="TextH1"><input name="conpwd"  type="password" value="<? echo $conpwd ?>" size="30" /></td>
          </tr>
          <tr>
            <td height="30" colspan="2"><span class="require">* Denotes a require_onced field</span></td>
          </tr>
          
          <tr>
            <td height="40" colspan="2" class="TextH1"><input name="btnUpdate" type="submit" class="btn" id="btnUpdate" value="Update" /></td>
          </tr>
        </table></td>
        <td><img src="images/border/09.gif" width="14" height="250" alt="" /></td>
      </tr>
 
    </table>
	</form>	</td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#333333"><div align="center"><span class="Footer">
      <br />
      <? require_once  "footer.php"; ?>
    </span></div></td>
  </tr>
</table>
</body>
</html>
