<?php
    session_start();
    include("dbconfig.php");
    
    
    
    if(isset($_SESSION['username']) && isset($_SESSION['password']))
    {
        $username=$_SESSION['username'];
        $pass=$_SESSION['password'];
        
        if(isset($_POST['edit'])){
            $doc_name = $_POST['doc_name'];
            $doc_specialization = $_POST['doc_specialization'];
            $doc_id = $_POST['doc_id'];
            
            $insert_doc = "UPDATE `docotorsList` SET `doc_name`= '$doc_name',`doc_specialization`='$doc_specialization',`created_by`='' WHERE `doc_id`='$doc_id' ";
            
            $rs = mysqli_query($db,$insert_doc);
            if($rs){
                $_SESSION['Updated']="Updated";
                header("Location: doctors.php");
            }
            
            
        }
        
        //add
        if(isset($_POST['addDoc'])){
            $doc_name = $_POST['doc_name'];
            $doc_specialization = $_POST['doc_specialization'];
            
            $insert_doc = "INSERT INTO `docotorsList`( `doc_name`, `doc_specialization`, `created_by`) VALUES ('$doc_name', '$doc_specialization', '$username')";
            
            $rs = mysqli_query($db,$insert_doc);
            if($rs){
                $_SESSION['added']="added";
                header("Location: doctors.php");
            }
            
            
        }
        
        
        
    }
    else
    {
         echo '<META http-equiv="refresh" content="0;logout.php">';
    }
?>