<?
include("../includes/site_config.php");

 $txtUser=form_get('mem_id');
#### If request is made for password Change.
if(isset($_REQUEST['change_password'])){

$WPassword=md5(form_get('WPassword'));


  $update=mysql_query("UPDATE members set mem_password='$WPassword' where MD5(mem_userid)='$txtUser'");

if($update){?>
<DIV align=center> 
		
		<font color="#FF0000">Password has been changed.</font><BR>
</DIV>

<? }
}

########

if(isset($txtUser)){
$sel=mysql_query("SELECT mem_username, mem_password from members where md5(mem_userid)='$txtUser'");
$mem=mysql_fetch_object($sel);
}
?>
<style type="text/css">
<!--
.text {font-size:11px;
}
-->
</style>

<!-- Validating Paasword field -->
<script>

function validate_password(){

if (document.password.WPassword.value.length < 6)
   {
     alert("Password Length");
     document.password.WPassword.focus();
     return (false);
   }

   if (document.password.WPassword.value.length > 20)
    {
      alert("Long Password");
      document.password.WPassword.focus();
      return (false);
   }

   if (document.password.WPassConfirm.value.length < 6)
   {
     alert("Confirm Password Length");
     document.password.WPassConfirm.focus();
     return (false);
   }

   if (document.password.WPassConfirm.value.length > 20)
    {
      alert("Long Confirm Password");
      document.password.WPassConfirm.focus();
      return (false);
   }
   
   if (document.password.WPassword.value != document.password.WPassConfirm.value)
    {
      alert("Password doesn't Match");
      document.password.WPassword.focus();
      return (false);
   }
}

</script>



<table width="100%" border="0" cellpadding="3" cellspacing="2">
<form name="password" action="<?=$_SERVER['PHP_SELF']?>" method="post" onSubmit="return validate_password();">
  <tr>
    <td colspan="2" bgcolor="#E6E6E6" class="titlehead"><strong>Change Password for <?=$mem->mem_username?></strong> </td>
  </tr>
  
  <tr>
    <td bgcolor="#E6E6E6">&nbsp;</td>
    <td bgcolor="#E6E6E6">&nbsp;</td>
  </tr>
  <tr>
    <td width="250" bgcolor="#e6e6e6" class="text"><span class="normal"><span class=mandatory>*</span> <?php echo REGISTER_PASSWORD?></span></td>
    <td bgcolor="#e6e6e6" class="text"><span class="tdeven">
      <input name="WPassword" type="password" class="input" id="WPassword" size="20" maxlength="20" value="<?=$mem->mem_password?>" tabindex='2'>
    </span></td>
  </tr>
  <tr>
    <td bgcolor="#e6e6e6" class="text">&nbsp;</td>
    <td bgcolor="#e6e6e6" class="text">&nbsp;</td>
  </tr>
  <tr>
    <td width="250" bgcolor="#e6e6e6" class="text"><span class="normal"><span class=mandatory>*</span> <?php echo REGISTER_CONFIRM?></span></td>
    <td align="left" bgcolor="#e6e6e6" class="text"><span class="tdodd">
      <input name="WPassConfirm" type="password" class="input" id="WPassConfirm" size="20" maxlength="20" value="<?=$mem->mem_password?>" tabindex='3'>
    </span></td>
  </tr>
  <tr>
    <td bgcolor="#e6e6e6" class="text">&nbsp;</td>
    <td bgcolor="#e6e6e6" class="text">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#e6e6e6" class="text"><div align="center">
      <input type="hidden" name="mem_id" value="<?=$txtUser?>">
      <input name="change_password" type="submit" value="Change Password" >
    </div></td>
  </tr>
  </form>
</table>
