<?php 
require_once '../config/db.php';
require_once '../config/database.class.php';
require_once '../config/functions.php';
$d = new database($db_config);


if(isset($_POST)){
    $post  =$_POST;
    $title = $post['title'];
    $description = $post['description'];
      /*$name = $_FILES['image']['name'];
    
 //Getting temporary file name stored in php tmp folder 
 $tmp_name = $_FILES['image']['tmp_name'];
 
 //Path to store files on server
 $path = '../uploads/';
  if(!empty($name)){
 //Moving file to temporary location to upload path 
 move_uploaded_file($tmp_name,$path.$name);
 
 //Displaying success message 
 //echo "Upload successfully";
 }else{
 //If file not selected displaying a message to choose a file 
 echo "Please choose a file";
 }
 //print_r($_FILES);
//exit();
 $file_url =$path.$name;*/
 

if($post['id']==''){
    $query = "INSERT INTO about(`title`,`description`) VALUES('$title','$description')";
        $executeQuery = $d->insertQuery($query);
        if($executeQuery){
            echo getResponse('success','Data saved successfully');
        }else{
            echo getResponse('error','Something went wrong, please try later!');
        }
    }else{
$id = $post['id'];
        $query = "UPDATE about SET title='".$title."',description='".$description."' WHERE id=$id";
        $executeQuery = $d->updateQuery($query);
        if($executeQuery){
            echo getResponse('success','Data updated successfully');
        }else{
            echo getResponse('error','Something went wrong, please try later!');
        }

    }
}
?>