<?php
 session_start();      
 if(empty($_SESSION['p0B_c0ff33'])) header('location:login.php?goto=index');
		
?>
<?php include('../db_function.php');  ?>

<?php
		if(isset($_POST['change'])){
		$old=$_POST['txtold'];
		$new=$_POST['txtnew'];
			$str="SELECT * FROM tbladmin";
			$sql=mysql_query($str);
			while($row=mysql_fetch_array($sql)){
				$p_old=$row['password'];
				if($old==$p_old){
					$str="UPDATE tbladmin SET password='$new' WHERE password='$old' ";
					$update=mysql_query($str);
					echo '<div style="margin-bottom:-32px; padding-top:10px; padding-left:15px; font-size:20px;" > Sucessful! </div>';
				}
				else{echo '<div style="margin-bottom:-32px; padding-top:10px; padding-left:15px; font-size:20px;" >Fail! </div>';}
			}
			
				
	}

?>
    <form name="phpformmailer" method="POST" action="" enctype="multipart/form-data" onsubmit="return validateForm()">
    
    <table border="0" cellpadding="0" cellspacing="0" width="700"  bgcolor="#C0C0C0" style="line-height:10px; font-size:14px;">
        <tr>
            <td height="35" bgcolor="#666666" width="257">&nbsp;</td>
            <td width="328" height="35" bgcolor="#666666" >
          <font style="color:#FFFFFF; font-size:14px; font-weight:bold;"> Change Password</font></td>
            <td height="35" bgcolor="#666666" width="46">&nbsp;</td>
        </tr>

        <tr height="20">
            <td align="right" width="257">&nbsp;</td>
          <td width="63%">&nbsp;</td>
            <td width="10">&nbsp;</td>
        </tr>
        
    
		<tr height="35">
            <td align="right"><font style="color:red; font-size:14px;">* </font>Old Password :&nbsp;</td>
            <td><input type="text" name="txtold" size="35"></td>
            <td width="10">&nbsp;</td>
        </tr>
		<tr height="35">
            <td align="right"><font style="color:red; font-size:14px;">* </font>New Password :&nbsp;</td>
            <td><input type="text" name="txtnew" size="35"></td>
            <td width="10">&nbsp;</td>
        </tr>
		<tr height="35">
            <td align="right" width="400"><font style="color:red; font-size:14px;">* </font>Confirm New Password :&nbsp;</td>
            <td><input type="text" name="txtnew2" size="35"></td>
            <td width="10">&nbsp;</td>
        </tr>
		<tr height="30px">
            <td align="right" width="257">&nbsp;</td>
        </tr>
            <td align="right" width="257">&nbsp;</td>
            <td><input type="submit" value="Change" name="change">&nbsp;
            <input type="reset" value="Reset" name="Reset"></td>
            <td width="10">&nbsp;</td>
        </tr>
		 <tr height="30px">
            <td align="right" width="257">&nbsp;</td>
        </tr>
                
    </table>           
        
    </form>
	<script language="JavaScript"><!--
function validateForm() 
{
 var okSoFar=true
 with (document.phpformmailer)
 {

  var e1 = txtnew.value
  var e2 = txtnew2.value
  if (!(e1==e2) && okSoFar)
  {
    okSoFar = false
    alert ("The new password you entered do not match.  Please re-enter !")
    txtnew.focus()
  }
  if (txtold.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter the old password !")
    txtold.focus()
  }
  if (txtnew.value=="" && okSoFar)
  {
    okSoFar=false
    alert("Please enter the new passowrd !")
    txtnew.focus()
  }
  if (okSoFar==true)  
  {
   block_spam_bots.value=4*3;//spam bots currently can not read JavaScript, if could then they'd fail the maths!
   return true;                  // do check for updatea often at:  www.TheDemoSite.co.uk 
  }
  else
  {
	return false
  }
 }
}
// --></script>
 
  </div>        
  
</body>

</html>