0

Strange error. I've tested to use or and it's not working.

I have a form which I need to send the value of the submit button, here it's should be 'save' for the $_POST['saveBtn']

My form is declared like this :

<form id="clientFrm" action="index.php" class="form-horizontal form-label-left" method="post">

I have tried this :

<button id="saveBtn" name="saveBtn" type="submit" class="btn btn-success" value="save">save</button>

or

When I do a var_dump in Firefox (or IE or Edge), I get that :

array(16) {
["IDCompagnie"]=> string(1) "1"
["Nom"]=> string(14) "Test"
["Adresse"]=> string(10) "test111111"
["Ville"]=> string(0) "" }

And when I do it in Chrome, everything works well! Here the var_dump in Chrome :

array(17) { ["IDCompagnie"]=> string(1) "1"
["Nom"]=> string(14) "MI-Consultants"
["Adresse"]=> string(7) "test111"
["Ville"]=> string(0) ""
["saveBtn"]=> string(4) "save" }

I only have one element named with 'saveBtn' in my form...

Do you know why it's only working on Chrome?

Here's the complete code :

    <?php  
$currentURL='index.php';
include 'header.php';

$db->connect();
//var_dump($_POST);

if( ISSET( $_POST['saveBtn'] ) && $_POST['saveBtn'] == 'save'){
    unset($_POST['saveBtn']);
    unset($_POST['telephone1']);
    unset($_POST['telephone2']);
    include 'misc/bd/saveCompagnie.php';
}

$cie = $db->getOne('compagnie');
if($cie){
    foreach ($cie as $key => $value){
        $$key = $value;
    }
}

$db->where('IDCompagnie = 1');
$users = $db->get('user');

$db->__destruct();
?>
    <!-- page content -->
    <div class="right_col" role="main">
    <div class="">
            <div class="page-title">
                <div class="title_left">
                    <h3>Modifier Informations Compagnie</h3>
                    <?php //var_dump($cie); ?>
        </div>
        </div>
        <div class="clearfix"></div>
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
                <div class="x_title">
                    <h2>Informations générales </h2>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                    <br />
                    <form id="clientFrm" action="index.php" data-parsley-validate class="form-horizontal form-label-left" method="post">
                        <input type="hidden" id="IDCompagnie" name="IDCompagnie" value="<?php echo ISSET($IDCompagnie) ? $IDCompagnie : '' ?>">
                                <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="Nom">Nom <span class="required">*</span></label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="Nom" name="Nom" class="form-control col-md-7 col-xs-12" required="required" type="text" value="<?php echo ISSET($Nom) ? $Nom : '' ?>">
                        </div>
                        </div>
                        <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="Adresse">Adresse</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="Adresse" name="Adresse" class="form-control col-md-7 col-xs-12" type="text" value="<?php echo ISSET($Adresse) ? $Adresse : '' ?>">
                        </div>
                        </div>
                        <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="Ville">Ville</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
                            <input id="Ville" name="Ville" class="form-control col-md-7 col-xs-12" type="text" value="<?php echo ISSET($Ville) ? $Ville : '' ?>">
                        </div>
                        </div>
                        <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="Province">Province</label>
                        <div class="col-md-2 col-sm-2 col-xs-12">
                            <input id="Province" name="Province" class="form-control col-md-7 col-xs-12" type="text" value="<?php echo ISSET($Province) ? $Province : '' ?>">
                        </div>
                        <label class="control-label col-md-2 col-sm-2 col-xs-12" for="CodePostal">Code Postal</label>
                        <div class="col-md-2 col-sm-2 col-xs-12">
                            <input id="CodePostal" name="CodePostal" type="text" class="form-control" value="<?php echo ISSET($CodePostal) ? $CodePostal : '' ?>">
                        </div>
                        </div>
                        <div class="item form-group">
                        <label class="control-label col-md-3 col-sm-3 col-xs-12" for="telephone">Téléphone</label>
                        <div class="col-md-2 col-sm-2 col-xs-12">
                            <input id="telephone1" name="telephone1" type="text" class="form-control" data-inputmask="'mask' : '(999) 999-9999'" value="<?php echo ISSET($Telephone1) ? $Telephone1 : '' ?>">
                            <span class="fa fa-phone form-control-feedback right" aria-hidden="true"></span>
                            <input id="Telephone1" name="Telephone1" type="hidden" value="<?php echo ISSET($Telephone1) ? $Telephone1 : '' ?>">
                        </div>
                        <label class="control-label col-md-2 col-sm-2 col-xs-12" for="telephone">Téléphone</label>
                        <div class="col-md-2 col-sm-2 col-xs-12">
                            <input id="telephone2" name="telephone2" type="text" class="form-control" data-inputmask="'mask' : '(999) 999-9999'" value="<?php echo ISSET($Telephone2) ? $Telephone2 : '' ?>">
                            <span class="fa fa-phone form-control-feedback right" aria-hidden="true"></span>
                            <input id="Telephone2" name="Telephone2" type="hidden" value="<?php echo ISSET($Telephone2) ? $Telephone2 : '' ?>">
                        </div>
                        </div>
                        <div class="clear-margin"></div>
                        <div class="x_title">
                            <h2>Autres Informations </h2>
                            <div class="clearfix"></div>
                        </div>
                         <div class="item form-group">
                        <label class="control-label col-md-2 col-sm-2 col-xs-12" for="TauxHoraire">Taux Horaire</label>
                        <div class="col-md-2 col-sm-2 col-xs-12">
                            <input type="text" id="TauxHoraire" name="TauxHoraire" min="0" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($TauxHoraire) ? $TauxHoraire : '' ?>">
                            <span class="fa fa-usd form-control-feedback right" aria-hidden="true"></span>
                        </div>
                        <label class="control-label col-md-2 col-sm-2 col-xs-12" for="Financement">Financement</label>
                        <div class="col-md-2 col-sm-2 col-xs-12">
                            <input type="text" id="Financement" name="Financement" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($Financement) ? $Financement : '' ?>">
                            <span class="fa fa-percent form-control-feedback right" aria-hidden="true"></span>
                            </div>
                                    <label class="control-label col-md-2 col-sm-2 col-xs-12" for="EntenteSignature">Entente Signature</label>
                        <div class="col-md-2 col-sm-2 col-xs-12">
                            <input type="number" id="EntenteSignature" name="EntenteSignature" min="0" max="100" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($EntenteSignature) ? $EntenteSignature : 50 ?>">
                            <span class="fa fa-percent form-control-feedback right" aria-hidden="true"></span>
                        </div>
                        </div>
                        <div class="clear-margin"></div>
                        <div class="x_title">
                            <h2>Valeurs constantes </h2>
                            <div class="clearfix"></div>
                        </div>
                         <div class="item form-group">
                            <label class="control-label col-md-2 col-sm-2 col-xs-12" for="CoutEnvoiPoste">Coût Envois Postaux (unitaire)</label>
                        <div class="col-md-2 col-sm-2 col-xs-12">
                            <input type="text" id="CoutEnvoiPoste" name="CoutEnvoiPoste" maxlength="5" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($CoutEnvoiPoste) ? $CoutEnvoiPoste : 0.00 ?>">
                            <span class="fa fa-usd form-control-feedback right" aria-hidden="true"></span>
                        </div>
                        <label class="control-label col-md-2 col-sm-2 col-xs-12" for="CoutMachineTimbre">Coût Machine à Timbre (mensuel)</label>
                        <div class="col-md-2 col-sm-2 col-xs-12">
                            <input type="text" id="CoutMachineTimbre" name="CoutMachineTimbre" maxlength="5" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($CoutMachineTimbre) ? $CoutMachineTimbre : 0.00 ?>">
                            <span class="fa fa-usd form-control-feedback right" aria-hidden="true"></span>
                            </div>
                                    <label class="control-label col-md-2 col-sm-2 col-xs-12" for="PctImpressionPapeterie">% d'impression et papeterie</label>
                        <div class="col-md-2 col-sm-2 col-xs-12">
                            <input type="number" id="PctImpressionPapeterie" name="PctImpressionPapeterie" min="0" class="form-control col-md-7 col-xs-12" value="<?php echo ISSET($PctImpressionPapeterie) ? $PctImpressionPapeterie : 0 ?>">
                            <span class="fa fa-percent form-control-feedback right" aria-hidden="true"></span>
                        </div>
                        </div>
                        <div class="larger clear-margin"></div>
                        <div class="x_title">
                            <h2>Listes des Utilisateurs </h2>
                            <div class="clearfix"></div>
                        </div>
                        <div class="item form-group">
                        <table id="datatable-buttons" class="table table-striped table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                                <thead>
                                <tr>
                                    <th>Nom</th>
                                    <th>Prénom</th>
                                    <th>Username</th>
                                    <!-- th>Rôle</th-->
                                  </tr>
                                </thead>
                                <tbody>
                                <?php 
                                foreach( $users as $row ) {
                                ?>
                                    <tr>
                                        <td><?php echo setEncodage($row['Nom'])?></a></td>
                                        <td><?php echo setEncodage($row['Prenom'])?></td>
                                        <td><?php echo setEncodage($row['Username'])?></td>
                                        <!-- td><?php //echo $row['Role']?></td-->
                                    </tr>
                                <?php 
                                }
                                ?>
                                </tbody>
                              </table>
                        </div>                                  
                    <div class="ln_solid"></div>
                    <div class="form-group">
                          <div class="col-md-12 col-md-offset-5">
                        <input id="cancelBtn" name="cancelBtn" type="button" class="btn btn-primary" value="Cancel">
                        <button id="saveBtn" name="saveBtn" type="submit" class="btn btn-success" value="save">Enregistrer</button>
                          </div>
                        </div>                                  
                    <div class="ln_solid"></div>
                    </form>
                </div>
            </div>
        </div>
        </div>
    </div>
    <!-- /page content -->



    <?php 
    include 'footer.php';
    include 'js/pageJS/indexJS.php' 
    ?>


</body>

</html>
sincos
  • 127
  • 2
  • 18
  • Not sure, Might be issue can be of syntax error like 'missing closing tag' or something? can you post your full code? – Rohit Jun 14 '16 at 00:35
  • Try using a `hidden` field instead. Submit buttons can be screwy for submitting data since only one button can ever be successful – Machavity Jun 14 '16 at 00:36
  • I've just update it with the full code. For the hidden field, it would be an idea – sincos Jun 14 '16 at 00:40
  • Possible duplicate of [Send value of submit button when form gets posted](http://stackoverflow.com/questions/22579616/send-value-of-submit-button-when-form-gets-posted) – Tony Chiboucas Jun 14 '16 at 00:41

0 Answers0