<?php
    session_start();
include("dbConfig.php");
   if(isset($_SESSION['username']) && isset($_SESSION['name']))
{
    $username=$_SESSION['username'];
    $name=$_SESSION['name'];
    
        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: addDoc.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: addDoc.php");
            }
            
            
        }
        
        
        
    }
    else
    {
         echo '<META http-equiv="refresh" content="0;logout.php">';
    }
?>