 <?php
 include_once('opendb.php');
 $mess="Error";
 

 $Action=$_POST["Action"]; 
 $CustCode=$_POST["CustCode"];
 $SmanCode=$_POST["SmanCode"];
 $Notes=$_POST["Notes"];
 $Rdate=$_POST["Rdate"];
 $CompID=$_POST["comp_id"];
 

if (isset($_POST["comp_id"])){
    if ($Action=='A'){
        $sql = "INSERT INTO sman_reminders (sub_code,sman_code,Notes,rem_date,comp_id,rem_type) VALUES ('$CustCode','$SmanCode','$Notes','$Rdate',$CompID,1)";
        if ($conn->query($sql) === TRUE)
        {
           $mess=$conn->insert_id;
        } else
        {
           die( "Error: Inserting Reminder " . $sql . "<br>" . $conn->error);
        } 
        
    } elseif ($Action=='E') {

    } elseif ($Action=="D") {
        $sql = "delete from sman_reminders where comp_id=$CompID and Entry_no=$WebEntryNo";
        if ($conn->query($sql) === TRUE)
        {
            $mess=$WebEntryNo;
        }
        else {
             die( "Error: deleting Reminder " . $sql . "<br>" . $conn->error);
        }

    }
}
Else
{
    die( "ERROR: No company id!");
} 

echo $mess.error_get_last();
$conn->close();
?>