<?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;
	$phone= $post['phone'];
	$whatsapp= $post['whatsapp'];
	$address= $post['address'];
	$email1= $post['email1'];
	$email2= $post['email2'];

	

	if($post['id']==''){
    $query = "INSERT INTO contact(`phone`,`whatsapp`,`address`,`email1`,`email2`) VALUES('$phone','$whatsapp','$address','$email1','$email2')";
        $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 contact SET  phone='".$phone."',whatsapp='".$whatsapp."',address='".$address."',email1='".$email1."',email2='".$email2."' 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!');
        }

	}
}
?>