<?
include_once "includes/define.php";
require_once('includes/configure.php');
require_once "admin/include/function.php";

if(isset($_POST['btnResetPwd'])) {
	$sql = "SELECT * from ivc_members where im_email='$email'";
	$result =mysql_query($sql)or die(mysql_error());
	if(mysql_num_rows($result)==0)  
	{
	     $action_msg = "Invalid email.";
	}else{
		$pwd=generatePassword();		
		$sql = "update ivc_members set im_pwd='".md5($pwd)."' WHERE im_email='$email'";		
		@mysql_query($sql)or die(mysql_error());
					
		$ret_email=email_notification("FORGOTPWD","ENG");																	
														
		$message=str_replace("{newpwd}",$pwd,$ret_email[message]);
		
		mail($email,$ret_email[subject],$message,'From:'.EMAIL);	

		$action_msg="Your new password is already sent, please check your email !";	

	}

}

?>
<!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" />
<title><?=TITLE?></title>
<!-- SmartMenus 6 config and script core files -->
<script type="text/javascript" src="c_config.js"></script>
<script type="text/javascript" src="c_smartmenus.js"></script>

<!-- SmartMenus 6 config and script core files -->
<script src="includes/validation.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="styles.css" >

</head>

<body>
<table width="1000" height="600" border="0" align="center" cellpadding="0" cellspacing="0" id="Table_01">
  <tr>
    <td height="82" background="images/iconic_01.jpg"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="91%" height="30" align="right" valign="bottom" class="topmenu"><? include_once "includes/topmenu.php"; ?></td>
        <td width="9%" rowspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td height="4"></td>
      </tr>
      <tr>
        <td height="14" align="right">
          <? include_once "includes/menu.php"; ?>
</td>
        <td height="29" rowspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td height="3" align="right"></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="500" valign="top" background="images/login_bg.jpg" style="background-repeat: no-repeat">
    
      <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="647" height="340" valign="bottom"><span class="title1">FORGOT PASSWORD</span></td>
        </tr>
        <tr>
          <td height="21" valign="top"><? echo "<div class='Msg'>$action_msg</div>" ?></td>
        </tr>
        <tr>
          <td ><table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
              <td width="789" ><form action="<?=$PHP_SELF ?>" method="post"  name="formLogin" id="formLogin" onsubmit="return ValidateResetPwd(this)">
                <table width="100%" border="0" cellpadding="1" cellspacing="1">
                  <tr>
                    <td height="40" colspan="2">
                      <span class="text1">Just enter  your email to retrieve your  new password.</span><br />

                    </td>
                  </tr>
                  <tr>
                    <td width="227" class="subItem"><div align="right" class="text1">Email  : <span class="require">*</span> </div></td>
                    <td width="573" class="subItem"><span class="TextH1">
                      <input name="email" type="text" id="email" value="<? echo $email ?>" size="40" />
                    </span></td>
                    </tr>
                  <tr>
                    <td><div align="center"></div></td>
                    <td height="30"><span class="require">* Denotes a required field</span></td>
                    </tr>
                  <tr>
                    <td></td>
                    <td><span class="TextH1">
                      <input name="btnResetPwd" type="submit" class="btn" id="btnResetPwd" value="Reset Password" />
                    </span></td>
                    </tr>
                  <tr>
                    <td colspan="2">&nbsp;</td>
                    </tr>
                  </table>
                </form></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
            </tr>
          </table>            <p class="text1">&nbsp;</p></td>
        </tr>
        <tr>
          <td >&nbsp;</td>
        </tr>
        <tr>
          <td ><? include_once "includes/bottom.php" ?></td>
        </tr>
    </table></td>
  </tr>

</table>
</body>
</html>
