<?php
session_start();
    header('Access-Control-Allow-Origin:*');
    header('Content-Type; application/json; charset=utf-8');
    header('Access-control-Allow-Method: POST');
    header('Access-control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-request-With');
    include('db.php');
        $inputdata = json_decode(file_get_contents("php://input"), true);
        
        $intituler = $inputdata['intituler'];
        $montant = $inputdata['montant'];
        $user = $inputdata['user'];
      


            $pub=$db->prepare('INSERT INTO depense (intituler, montant, user) VALUES(?,?,?)');

            $req_user = $pub->execute(array($intituler, $montant, $user));

            if ($req_user) {
                //création réussie
                
                echo (json_encode(['response' => 1]));



            }else{
                // création non réussie

                echo (json_encode(['response' => 0]));

                

            }


        