<?php
if(isset($_POST['type'])){
    require_once('../../assets/config/config.php');
    $obj=new Database();
    if($_POST['type']=='add')
    {
    $user_name=$_POST['user_name'];
    $user_id=$_POST['user_id'];
    $password=md5($_POST['password']);
    $level=$_POST['level'];
    $date=date('d-M-Y');
    echo $obj->insert('user',['date'=>$date,'user_name'=>$user_name,'user_id'=>$user_id,'password'=>$password,'access_level'=>$level,'status'=>'Active']);
    }
    if($_POST['type']=='edit')
    {
        $user_name=$_POST['user_name'];
        $user_id=$_POST['user_id'];
        $password=md5($_POST['password']);
        $level=$_POST['id'];
        $id="id='".$level."'";
        echo $obj->update('user',['user_name'=>$user_name,'user_id'=>$user_id,'password'=>$password,'status'=>'Active'],$id);
    }
}
?>