<?php
include 'include/db.php';
include 'include/connect.php';
$id = $_POST['id'];

if(!empty($id) && $_POST['name'] != "0"){
                $data['admin_user'] = $_POST['user'];
                $data['admin_pass'] = $_POST['pass'];
                $data['admin_name'] = $_POST['name'];
                $data['admin_lastname'] = $_POST['lastname'];
                $data['admin_nickname'] = $_POST['nickname'];
		$rs = $db->update('tbadmin',$data,'admin_id',$id);
           if($rs){
            echo "0";
           } else {
            echo "00";
           }

     } else {

      if($_POST['name'] != "0") {
           
      $rs = $db->insert('tbadmin',array(
       'admin_user' => $_POST['user'],
       'admin_pass' => $_POST['pass'],
       'admin_name' => $_POST['name'],
       'admin_lastname' => $_POST['lastname'],
       'admin_nickname' => $_POST['nickname']
            ));

           if($rs){
            echo "2";
           } else {
            echo "0";
           }
         } else {
            echo "3";
        }
}
?>

