<?php
error_reporting(0);
@session_start();
include("config.php");



$ename=$_POST[ename];
$mobile=$_POST[mobile];
$password=$_POST[password];

 $branch = $_SESSION[branch];


$flag = $_REQUEST[flag];
$mode = $_REQUEST[mode];

/***********************************/
$id= $_POST[id];
if($id=="")
{ 
    	 $query_insert=sprintf("Insert INTO employee SET 
		         emp_name='$ename',
		           	emp_mobile='%s',   
				   	password='%s',
				  permition='approve',  branch='$branch'
				 ",$mobile,$password); 
		
		if(!($resi=mysql_query($query_insert))){echo $query_insert.mysql_error(); exit;}
							
		header("Location:add-employee.php?flag=dn");
		exit;
}
$id= $_POST[id];
if($id!="")
{
          $query_up=sprintf("UPDATE employee SET 
		  emp_name='$ename',
		           	emp_mobile='%s',   
				   	password='%s'
				   WHERE id='%d' ",$mobile,$password,$id); 
		   if(!($resu=mysql_query($query_up))){echo $query_up.mysql_error(); exit;}
   
		
	
		header("Location:employee-list.php?flag=up");
		exit;
		
		}
?>
