<?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);
        
        $repas = $inputdata['repas'];
        $designation = $inputdata['designation'];
        $prix = $inputdata['prix'];
        $prix_achat = $inputdata['prix_achat'];
        $benefice = $prix-$prix_achat;
        $avec_accompagnement = $inputdata['avec_accompagnement'];
        $est_un_accompagnement = $inputdata['est_un_accompagnement'];
      


            $user=$db->prepare('INSERT INTO prix_repas (repas, designation, prix, prix_achat, benefice,avec_accompagnement,est_un_accompagnement) VALUES(?,?,?,?,?,?,?)');

            $req_user = $user->execute(array($repas, $designation, $prix,$prix_achat,$benefice,$avec_accompagnement,$est_un_accompagnement));

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



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

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

                

            }


        