<?php
include("protect.php");
include("dbconnect.php");
extract($_POST);
$rdate=date("d-m-Y");
if(isset($btn))
{
$q1=mysql_query("select * from register where account='$account'");
$n1=mysql_num_rows($q1);
		if($n1==1)
		{
		$ins=mysql_query("update register set deposit=deposit+$deposit where account='$account'");
		$mq = mysql_query("select max(id) as maxid from event");
			$mr=mysql_fetch_array($mq);
			$id = $mr['maxid']+1;
			$n=mysql_query("insert into event(id,account,event,transfer_to,amount,rdate) values($id,'$account','Deposit','','$deposit','$rdate')");
		if($ins)
		{
		?>
		<script language="javascript">
		alert("Deposit Success...");
		window.location.href="view_cus.php";
		</script>
		<?php
		}
		
		
		
		}
		else
		{
		$msg="Invalid Account!";
		}
		
}
?>
<!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>
<title><?php include("title.php"); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="style.css" rel="stylesheet" type="text/css" />
 <script language="javascript">
            function validate()
            {
			  
                
               if (document.form1.deposit.value == "")
                {
                    alert("Enter the Deposit Amount");
                    document.form1.deposit.focus();
                    return false;
                }
				if (isNaN(document.form1.deposit.value))
                {
                    alert("Invalid Deposit Amount!");
                    document.form1.deposit.select();
                    return false;
                }
               
                return true;
            }
        </script>
<!-- CuFon ends -->
</head>
<body>
        <form id="form1" name="form1" method="post" action="">
		<div class="sd"><!--<a href="index.php">Home</a>-->
    <?php include("link_admin.php"); ?>
  </div>
          <h2 align="center">Customer Amount Deposit </h2>
          <table width="342" height="197" border="0" align="center" class="bg1">
            <tr>
              <th align="left" scope="row">Account No. </th>
              <td align="left"><input type="text" name="account" /></td>
            </tr>
            <tr>
              <th align="left" scope="row"> Deposit Amount </th>
              <td align="left"><input type="text" name="deposit" /></td>
            </tr>
            <tr>
              <th colspan="2" scope="row"><input type="submit" name="btn" value="Submit" onClick="return validate()" /></th>
            </tr>
          </table>
          <p align="center" class="msg"><?php echo $msg; ?></p>
		  <p>&nbsp;</p>
		  <p align="center" class="sd"><?php include("title.php"); ?></p>
        </form>
       
        
</body>
</html>