<?php  
    $leave="";
    if(isset($_POST['update']))
    {
        $leave = mysql_real_escape_string($_POST['leave']);
        $id =  mysql_real_escape_string($_GET['id']);
        
        if(!$id){
            echo'<div class="alert alert-danger absolue center text-center" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                    <span class="text-danger">Error occured while trying to fetch leave info.</span>
                </div>';
        }else
        if(!$leave){
            echo'<div class="alert alert-danger absolue center text-center" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span>
                    </button>
                    <span class="text-danger">Enter Leave Name</span>
                </div>';
        }else 
        {
            if(!$insert = mysql_query("UPDATE school_leave_type SET name='$leave',updated_by='$stafNo' WHERE leaveID='$id'")){
                echo'<div class="alert alert-danger absolue center text-center" role="alert">
                        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                            <span aria-hidden="true">×</span>
                        </button>
                        <span class="text-danger">'.mysql_error().'</span>
                    </div>';
            }else
            {
                $pass="";
                $_SESSION['success']="true";
                header('Location:leave.php');
                echo "<script type='text/javascript'> document.location = 'leave.php'; </script>";
                exit();
            }
        }
       
    }  
?>