<?php
session_start();
include 'dbc.php';

$userid=$_SESSION["userid"];
$today=date("d-m-Y");
$sub_name=$_POST["sub_name"];
$exame_term=$_POST["exame_term"];
$month_name=$_POST["month_name"];
$class_name=$_POST["class_name"];
$std_rollno=$_POST["std_rollno"];
$obt_mark=$_POST["obt_mark"];
$total_mark=$_POST["total_mark"];
$sql = "select * from admission where std_rollno='$std_rollno' and class_name='$class_name' and user_id='$userid'";
   $appl=mysql_query($sql) or die("Error : " . mysql_error());
   $app=mysql_fetch_array($appl);
   if ($app==0)
   {
     echo "Wrong Student Roll No <a href='1st_term_exame_entry.php'>Retry</a>";
   }
else
{
$std_name=$app["std_name"];
$cell_1=$app["cell_1"];
 $father_name=$app["father_name"];
$percentage=$obt_mark / $total_mark * 100;

if ($percentage >=33)
{
$status="pass";
}
else
{
$status="fail";
}

$sql3 = "Insert into test (id,date,sub_name,exame_term,month_name,class_name,std_rollno,std_name,cell_1,obt_mark,total_mark,percentage,status,user_id) values (null,'$today','$sub_name','$exame_term','$month_name','$class_name','$std_rollno','$std_name','$cell_1','$obt_mark','$total_mark','$percentage','$status','$userid')";
mysql_query($sql3) or die("Error : " . mysql_error());
	
	header("location:test_entry.php");
}	
?>