Site icon Hip-Hop Website Design and Development

my kind doesn’t insert any information within the database

context : creation of a template and a plug-in

I’ve a kind (short_code) that I inject in a customized web page, it takes into consideration all of the values and makes its calculation however doesn’t insert any information in base, it returns a false once I make a print_r ?
who might enlighten me?

perform carbonFootprint_form() {
    ob_start();
    

    if (isset($_POST['carboneFootprint'])) {
        $consoelec = sanitize_text_field($_POST["consoelec"]);
        $consogaz = esc_attr($_POST["consogaz"]);
        $utiltransport = esc_attr($_POST["utiltransport"]);
        $nbsvoiture = sanitize_text_field($_POST["nbsvoiture"]);
        $typevehicule = esc_attr($_POST["typevehicule"]*($_POST["nbsvoiture"]));
        $consovehicule = sanitize_text_field($_POST["consovehicule"]);
        $typecarburant = esc_attr($_POST["typecarburant"]);
        $consoviande = esc_attr($_POST["consoviande"]);
        $typeviande = esc_attr($_POST["typeviande"]);
        $importviande = esc_attr($_POST["importviande"]);
        $consoproduitlaitier = esc_attr($_POST["consoproduitlaitier"]);
        $importproduitlaitier = esc_attr($_POST["importproduitlaitier"]);
        $emballage = esc_attr($_POST["emballage"]);
        $compostage = esc_attr($_POST["compostage"]);
        $dechet = esc_attr($_POST["dechet"]);
        $santeeductionetc = esc_attr($_POST['santeeductionetc']);
        $traget = esc_attr($_POST["traget"]);
        $depensepersonnelles  = esc_attr($_POST["depensepersonnelles"]);
        $whole =
            $consoelec
            + $$consogaz
            + $nbsvoiture
            + $typevehicule
            + $consovehicule
            + $typecarburant
            + $typeviande
            + $importviande
            + $importproduitlaitier
            + $emballage
            + $compostage
            + $dechet
            + $santeeductionetc
            + $traget
            + $depensepersonnelles
        ;
        
        
        if ( $consoelec != '' 
            && $consogaz  != '' 
            && $utiltransport  != '' 
            && $nbsvoiture != ''
            && $typevehicule != ''
            && $consovehicule != ''
            && $typecarburant != ''
            && $consoviande != ''
            && $typeviande != ''
            && $importviande != ''
            && $consoproduitlaitier != ''
            && $importproduitlaitier != ''
            && $emballage != ''
            && $compostage != ''
            && $dechet != ''
            && $santeeductionetc != ''
            && $traget != ''
            && $depensepersonnelles != ''
            && $whole != '')
            {
            international $wpdb;
            
            $table_name = $wpdb->prefix . 'carbonfootprints';
    
            $wpdb->insert( 
                $table_name,
                array( 
                    'consoelec' =>$consoelec,
                    'consogaz' =>$consogaz,
                    'utiltransport'=> $utiltransport,
                    'nbsvoiture '=>$nbsvoiture,
                    'typevehicule' =>$typevehicule,
                    'consovehicule' =>$consovehicule,
                    'typecarburant' =>$typecarburant,
                    'consoviande' =>$consoviande,
                    'typeviande' =>$typeviande,
                    'importviande' =>$importviande,
                    'consoproduitlaitier'=>$consoproduitlaitier,
                    'importproduitlaitier '=>$importproduitlaitier,
                    'emballage' =>$emballage,
                    'compostage' =>$compostage,
                    'dechet' =>$dechet,
                    'santeeductionetc'=>$santeeductionetc,
                    'traget' =>$traget,
                    'depensepersonnelles '=>$depensepersonnelles,
                    'whole' =>$whole
                )
                
            );
            ?>
            <pre>
                <?=var_export( $wpdb->insert( 
                $table_name,
                array( 
                    'consoelec' =>$consoelec,
                    'consogaz' =>$consogaz,
                    'utiltransport'=> $utiltransport,
                    'nbsvoiture '=>$nbsvoiture,
                    'typevehicule' =>$typevehicule,
                    'consovehicule' =>$consovehicule,
                    'typecarburant' =>$typecarburant,
                    'consoviande' =>$consoviande,
                    'typeviande' =>$typeviande,
                    'importviande' =>$importviande,
                    'consoproduitlaitier'=>$consoproduitlaitier,
                    'importproduitlaitier '=>$importproduitlaitier,
                    'emballage' =>$emballage,
                    'compostage' =>$compostage,
                    'dechet' =>$dechet,
                    'santeeductionetc'=>$santeeductionetc,
                    'traget' =>$traget,
                    'depensepersonnelles '=>$depensepersonnelles,
                    'whole' =>$whole
                )))?>
            </pre>
            <?php 


            ?>
            
                <div class="box">
                    <h4>Merci! pour votre participation
                    </h4>
                    votre emmetez un whole de <?= $whole ?> en gaz a effet de serre par an
                </div>


            <?php

        
        }
    }

?>

<kind methodology="POST" motion="">
    <div class="cont">
        <div class="cont ColX2">
            
            <fieldset>
                <legend>Habitation</legend>
            
                <label for="consoelec"> Indiquez votre consommation d'électricité en KWH/an
                    <enter sort="number" id='consoelec' identify="consoelec">
                </label>


                <div class="checkbox">
                    <enter sort="checkbox" identify="consogaz" id="consogaz" worth='787'>
                    <label for="consogaz">Cocher, si vous utilisez le gaz pour chauffer votre habitat</label>
 
                </div>
            </fieldset>

            <fieldset>
                <legend>Transport</legend>
            

                <div class="checkbox">
                    <enter sort="checkbox" identify="utiltransport" id="utiltransport" worth="10">
                    <label for="utiltransport">Cocher, si vous utilisez votre vehicule personnel </label>

                </div>

                <label for="nbsvoiture"> combien de vehicule possedez-vous?
                    <enter sort="number" id='nbsvoiture' identify="nbsvoiture" min="0" max="4">
                </label>
                <label for="typevehicule"> Quel sort de vehicule:
                    <choose identify="typevehicule" id="typevehicule">
                        <choice worth="">--Choisir un type--</choice>
                        <choice worth="22">berline</choice>
                        <choice worth="40">4x4</choice>
                        <choice worth="33">SUV</choice>
                        <choice worth="15">élèctrique</choice>
                    </choose>
                </label>


                <label for="typecarburant"> Quel sort de carburant:
                    <choose identify="typecarburant" id="typecarburant">
                        <choice worth="">--Choisir un type--</choice>
                        <choice worth="267">Diesel</choice>
                        <choice worth="228">Essence</choice>

                    </choose>
                </label>

                <label for="consovehicule"> Indiquez votre consommation de carburant en Cfp/an
                    <enter sort="number" id='consovehicule' identify="consovehicule">
                </label>

                <label for="traget"> Indiquez combien de kilometre vous parcourer pour vous rendre a votre travail
                    <enter sort="range" class="range" identify="traget" id="traget" min="0" max="100"
                        worth="50" step="10">
                </label>
            </fieldset>

            <fieldset>
                <legend>Alimentation</legend>
            

                <div class="checkbox">
                    <enter sort="checkbox" identify="consoviande" id="consoviande" worth="9">
                    <label for="consoviande">cochez, si vous consommez de la viande </label>

                </div>

                <label for="typeviande"> Quel sort de viande:
                    <choose identify="typeviande" id="typeviande">
                        <choice worth="">--Choisir un type--</choice>
                        <choice worth="650">Bovine</choice>
                        <choice worth="200">Porcine</choice>
                        <choice worth="650">Ovine</choice>
                        <choice worth="50">Volaille</choice>
                        <choice worth="10">Poisson</choice>

                    </choose>
                </label>

                <div class="checkbox">
                    <enter sort="checkbox" identify="importviande" id="importviande" worth="6400">
                    <label for="importviande">Cocher, si la viande est problem de l'importation</label>

                </div>
                <div class="checkbox">
                    <enter sort="checkbox" identify="consoproduitlaitier" id="consoproduitlaitier" worth="1640">
                    <label for="consoproduitlaitier">Cocher, si vous consommez des produit laitier</label>

                </div>

                <div class="checkbox">
                    <enter sort="checkbox" identify="importproduitlaitier" id="importproduitlaitier" worth="6400">
                    <label for="importproduitlaitier">Cocher, si les produit laitier sont problem de l'import</label>

                </div>
            </fieldset>

            <fieldset>
                <legend>Déchets</legend>
            
                <div class="checkbox">
                    <enter sort="checkbox" identify="emballage" id="emballage" worth="1870">
                    <label for="emballage">Cocher, si vous acheter de produit emballé </label>

                </div>
                <div class="checkbox">
                    <enter sort="checkbox" identify="compostage" id="compostage" worth="3333">
                    <label for="compostage">Cocher, si vous faites du compostage</label>

                </div>
                <div class="checkbox">
                    <enter sort="checkbox" identify="dechet" id="dechet" worth="125">
                    <label for="dechet">Cocher, si vous recyclez vos déchet</label>

                </div>

                <enter sort="hidden" identify="santeeductionetc" worth="11">
            </fieldset>

            <fieldset>
                <legend>Dépense Personnelles</legend>
                <label for="depensepersonnelles"> Indiquez la somme en moyenne de vos dépenses personnelles                                    
                    <enter sort="range" class="range" identify="depensepersonnelles" id="depensepersonnelles" min="0" max="100000" worth="50000" step="100">
                </label>

            </fieldset>

            

            <button sort="submit" identify="carboneFootprint">calculer mon empreinte carbonne</button>
            

        </div>
    </div>

 


</kind>





<?php

    return ob_get_clean();
}
add_shortcode('carboneFootprint', 'carbonFootprint_form');