<?php
session_start();
ob_start();
include("config/database.php");
$conct  = new connectionCreat();
$conct->connectToDB();
$conct->selectDB();
include "config/function.php";
$take_action1   = new actionDo();
?>
<form action="" method="POST" enctype="multipart/form-data">
  <input type="file"  name="file" >
 <input type= "submit" name="upload" value ="Upload" >
</form>
<?php
if(isset($_SESSION['msg']))
{
	echo $_SESSION['msg'];
	unset($_SESSION['msg']);	
}
if(isset($_POST['upload']))
{
	$file   = $_FILES['file']['tmp_name'];
	$handle = fopen($file, "r");
	$i		= 0;$j		= 0;$k		= 0;
	while(($filesop = fgetcsv($handle, 1000, ",")) !== false)
	{
		if($i>0)
		{
			//and `fname`='".$filesop[15]."' 
			$sql_2 		= mysql_query(" select * from `tbl_emp_records` where `emp_name`='".$filesop[2]."' and `state`='".$filesop[6]."' ")or die(mysql_error()); 
			if(mysql_num_rows($sql_2)>0)
			{				
				$sql 	= mysql_query(" update `tbl_emp_records` SET `dob`='".date('Y-m-d',strtotime($filesop[12]))."' where `emp_name`='".$filesop[2]."' and `fname`='".$filesop[15]."' and `state`='".$filesop[6]."' ")or die(mysql_error());
//echo "<br />";
				$j++;
			}
	   }
	$i++;
	}
	if($i>0)
	{
		$_SESSION['msg'] = "Total Records Uploaded : ".($i-1)."<br />Total Update Range : $j";
	}
	else
	{
		$_SESSION['msg'] = "Sorry! There is some problem.";
	}
	header("location:dob_update.php");
}
 ?>