<?php require_once('../auth/auth.php'); ?>
<?php 
	if (isset($_POST['n_id'])) {
        $note_head    = $_POST['note_head'];
        $editor       = $_POST['editor'];
        $n_id         = $_POST['n_id'];

        if ($n_id=='0') {
            mysqli_query($conn,"INSERT INTO notebook(`coid`, `bid`, `brid`, `note_head`, `note_body`, `userid`, `date`, `active`) 
                        VALUES ('$coid','$bid','$brid','$note_head','$editor','$uid','$datetime',1)")or die(mysqli_error($conn));
            } else if($n_id >0){
            mysqli_query($conn,"UPDATE notebook SET note_head='$note_head',note_body='$editor' WHERE n_id='$n_id'");
        }
	}


    if (isset($_POST['del_n_id'])) {
       $del_n_id  = $_POST['del_n_id'];
       mysqli_query($conn,"DELETE FROM notebook WHERE coid='$coid' AND bid='$bid' AND brid='$brid' AND n_id='$del_n_id' ") or die(mysqli_error($conn));
    }
?>	