	<?php 

include 'dbc.php';



$userid=$_SESSION["userid"];
$id=$_POST["id"];
$std_rollno=$_POST["std_rollno"];
$std_name=$_POST["std_name"];
$father_name=$_POST["father_name"];
$dob=$_POST["dob"];
$class_name=$_POST["class_name"];
$home_adress=$_POST["home_adress"];
$cell_1=$_POST["cell_1"];
$cell_2=$_POST["cell_2"];
$monthly_fee=$_POST["monthly_fee"];
$annual_fee=$_POST["annual_fee"];
$code=$_POST["code"];
$bal=$_POST["bal"];
$allied_code=$_POST["allied_code"];
$sec_fee=$_POST["sec_fee"];

$username=$_SESSION['username'];
$sql1 = "select * from admission where std_rollno='$std_rollno' and user_id='$userid'";
   $std_ledger1=mysql_query($sql1) or die("Error : " . mysql_error());
   $app1=mysql_fetch_array($std_ledger1);
   $pre_monthly_fee =$app1["monthly_fee"];
   $prebal =$app1["bal"];
   $preanbal =$app1["anbal"];
   
   $diff_monthly_fee = $pre_monthly_fee - $monthly_fee;
   $lessbal = $prebal - $bala;
   $lessanbal = $preanbal - $anbal;
   
   
$sql = "update admission set 
std_rollno='$std_rollno', std_name='$std_name', father_name='$father_name', dob='$dob', home_adress='$home_adress', cell_1='$cell_1', cell_2='$cell_2', monthly_fee= '$monthly_fee', annual_fee='$annual_fee', code='$code', bal='$bal', allied_code='$allied_code', sec_fee='$sec_fee' where id='$id'";
mysql_query($sql) or die("Error : " . mysql_error());

$sql3 = "Insert into diffeebal (id,date,std_rollno,std_name,father_name,pre_monthly_fee,cur_monthly_fee,diff_monthly_fee,prebal,curbal,lessbal,username,user_id,remarks,preanbal,curanbal,lessanbal) values (null,'$today','$std_rollno','$std_name','$father_name','$pre_monthly_fee','$monthly_fee','$diff_monthly_fee','$prebal','$bala','$lessbal','$username','$userid','$remarks','$preanbal','$anbal','$lessanbal')";
mysql_query($sql3) or die("Error : " . mysql_error());

echo "Record Update";
/*$sql="Select * from agents where userid='$user_id'";
$data=mysql_query($sql) or die ("Error:" . mysql_error());
$userdata=mysql_fetch_array($data);
$email=$userdata["e_mail"];
mail($email . ",info@lalburj.com","Candidate Information","Candidate Data Posted Successfully","Passport No:" . $app_pp_no . " of " . $app_name . "Has been Posted Successfully By:" . $_SESSION["userid"]);*/
?>
<a href="class_wise_search.php"> Back </a>