IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Conditions lors de l'envoi du formulaire


Sujet :

Langage PHP

  1. #1
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2013
    Messages
    55
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 55
    Points : 27
    Points
    27
    Par défaut Conditions lors de l'envoi du formulaire
    Bonsoir

    Grosso j'ai 2 conditions pour le submit de mon formulaire.

    En première condition (prioritaire) que le formulaire saisi avec les 2 premiers chiffres des départements suivant :

    93 / 95 / 60/ 62 / 80 / 59 / 02 / 27 / 28 / 76 / 14 / 50

    Soit envoyé sur l'adresse email A systématiquement et pour tous les autres départements, le formulaire soit envoyé avec la condition actuelle des jours pairs et impairs.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    <?php if( isset($_POST['submit']) ){ // le formulaire a été posté
    $tab_cp=array('93', '95', '60', '62' , '80' , '59' , '02' , '27' , '28' , '76' ,  '14' , '50'); // Tableaux des codes postaux
    $select_email=0;
     
    if(isset(!empty($tabLabelText[0]['element_id0-0']))
    {
        $cp=$tabLabelText[0]['element_id0-0'];
        $int_cp = intval(substr($cp,0,2)); //Troncature du code postal pour ne garder que les 2 premiers caracteres et transforme en entier
     if(in_array())
                $select_email=1; // Si code postal est dans la liste on choisi cet email
            }
       }
     
     
    if($select_email == '1'){
        echo 'adresseA@gmail.com'; //Mettre le code d'envoi email
        $formName="Devis TEST";
        $emailSubject="Informations transmises par le formulaire";
    }else{
        if( date("d") % 2 == 0 )
        echo 'adresseB@gmail.com';// nous sommes un jour pair
      else
        echo 'adresseA@gmail.com';// nous sommes un jour impair
        $formName="Devis TEST";
        $emailSubject="Informations transmises par le formulaire";
       }
    La condition des jours pairs et impairs fonctionne très bien individuellement.

    C'est celle sur le code postal qui ne fonctionne pas ?

    Je suis à l'aise en xhtml css mais pas trop en php.

    Pouvez-vous me donner le bon code pour que cela fonctionne?
    Voici le fichier en entier:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    <?php session_start(); header("Content-Type: text/html; charset=UTF-8"); ?>
    <?php
    /*
     * Formulaire généré par formallin v2.3.0
     * Auteur : Grégory Toucas
     * http://www.atomestudio.com / contact@atomestudio.com
     * Soutenu par l'agence web IDEEMATIC : http://www.ideematic.com
     *
     * Programme sous licence GPL:
     * http://www.gnu.org/licenses/gpl.html
     *
    */
    echo '
    <!--
    Formulaire généré par formallin v2.3.0
    Auteur : Grégory Toucas
    http://www.atomestudio.com / contact@atomestudio.com
    Soutenu par l agence web IDEEMATIC : http://www.ideematic.com
     
    Programme sous licence GPL:
    http://www.gnu.org/licenses/gpl.html
    -->
    ';
    ?>
    <?php
    $tabFieldsetLegends[5]="Titre";
    ?>
    <?php
    // Ensemble de fonctions
    function fa_phpToJs($var) {
        if (is_array($var)) {
            $res = "[";
            $array = array();
            foreach ($var as $a_var) {
                $array[] = fa_phpToJs($a_var);
            }
            return "[" . join(",", $array) . "]";
        }
        elseif (is_bool($var)) {
            return $var ? "true" : "false";
        }
        elseif (is_int($var) || is_integer($var) || is_double($var) || is_float($var)) {
            return $var;
        }
        elseif (is_string($var)) {
            return "\"" . addslashes(stripslashes($var)) . "\"";
        }
        // autres cas: objets, on ne les gère pas
        return FALSE;
    }
     
    function fa_str_post($string){
        if (isset($_POST[$string])) { $return_string = trim($_POST[$string]); } else { $return_string = ""; }
        return $return_string;
    }
    ?>
            <script type="text/javascript">
            var tabErrorFields=new Array();
            var tabErrorFormats=new Array();
            var tabFieldsRequired=new Array();
            var tabFormatsRequired=new Array();
            </script><?php $list_langIds="5"; $tab_langIds=explode(",",$list_langIds); ?>
    <?php
    $tabShortNames[0]="zh";
    $tabShortNames[1]="ca";
    $tabShortNames[2]="da";
    $tabShortNames[3]="de";
    $tabShortNames[4]="fr";
    $tabShortNames[5]="it";
    $tabShortNames[6]="pt";
    $tabShortNames[7]="ru";
    $tabShortNames[8]="es";
    $tabShortNames[9]="en";
    $tabShortNames[10]="ro";
    $tabShortNames[11]="pl";
    $tabShortNames[12]="nl";
    ?>
    <?php if(is_array($tabShortNames)){ $lang_id=array_search($_GET['lang'],$tabShortNames)+1; }else{ $lang_id=""; }?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $_GET['lang'];?>" xml:lang="<?php echo $_GET['lang'];?>">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title></title>
    <script type="text/javascript">var langId="<?php echo $lang_id;?>"; var issetCaptcha=false;</script>
    <style type="text/css">
     
            body {
                margin: 0px; padding: 0px; width:100%;
                font-family: "Trebuchet MS",arial,verdana, serif;
                font-weight: normal; font-size: 10px; color: #48566e;  text-align: left; /* line-height: 1.3em; */
                overflow-x: hidden;
                /* overflow-y: hidden; */
            }
     
            span.span_chbx_radio { float:left; width:200px; }
     
            input[type=submit] { opacity: 0.8; padding:5px; -moz-border-radius:5px; -webkit-border-radius:5px; -khtml-border-radius:5px; border:1px solid #E2E2E7; background-color:#8BA9DC; color:#ffffff; cursor: pointer;}
            input[type=reset] { opacity: 0.8; padding:5px; -moz-border-radius:5px; -webkit-border-radius:5px; -khtml-border-radius:5px; border:1px solid #E2E2E7; background-color:#f5f5f5; color:#333333; cursor: pointer;}
     
            input[type=submit]:hover, input[type=reset]:hover { opacity:0.5; }
     
            a { color:#48566e; }
     
            input[type=text], input[type=password] {
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;
                border:1px solid #8BA9DC;
                background-color:#ffffff;
                color:#48566e;
            }
     
            textarea {
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;
                border:1px solid #8BA9DC;
                background-color:#ffffff;
                color:#48566e; 
            }
     
            fieldset {
                border:1px solid #8BA9DC;
                background-color:#ffffff;
                margin: 5px;
                min-height: 100px;
                -moz-border-radius:5px;
                -webkit-border-radius:5px;
                -khtml-border-radius:5px;
            }
     
            legend {
                border:1px solid #ffffff;
                background-color: #ffffff;
                padding:4px;
                color:#8BA9DC;
                -moz-border-radius:4px;
                -webkit-border-radius:4px;
                -khtml-border-radius:4px;
                font-size:1.2em;
            }
     
            .errorMessage {
                font-size: 0.8em;
                color:#cc0000;  
            }
     
            .errorField, .errorFormat {
                background-color: #ffe6e6;
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;  
            }
     
            .submitError {
                padding:5px;
                color:#cc0000;
                border: 1px solid #cc0000;
                background-color: #ffe6e6;
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;
            }
     
            label, .span_chbx_radio {
                color:#48566e;
                font-size: 0.8em;
            }
     
            .obligatoryField {
                color:#cc0000;
                font-size: 1.2em;
            }
     
            #success {
                padding: 20px;
                font-size: 16px;
            }      
            </style>
    <link rel="stylesheet" type="text/css" href="http://jquery-ui.googlecode.com/svn/tags/latest/themes/base/jquery.ui.all.css" />
    <script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="../js/jquery-ui.min.js" type="text/javascript"></script>
    <script src="../js/jquery.ui.datepicker.min.js"></script>
    <script type="text/javascript">
    $(function(){ $(".datepicker").datepicker({changeMonth: true,changeYear: true}); });
    </script>
    <script type="text/javascript">function validForm(){
     
        /*
         * Initialisation des variables
         */
     
        var nbrErrors=0;
     
     
        /*
         * Fonctions de vérification des formatages
         */
     
        function verifNumber(myString){ // idTag 3 
            if(isNaN(myString)){ return false; }else { return true; }  
        }
     
     
        function verifEmail(myString){ // idTag 4
     
            var reg= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
     
            if(reg.test(myString)==true){
                return true; // adresse valide
            }
            else{
                return false; // adresse non valide
            }
        }
     
     
        function verfifUrl(myString){ // idTag 5
     
            var reg= /(http):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
     
            if(reg.test(myString)==true){
                return true; // adresse valide
            }
            else{
                return false; // adresse non valide
            }
     
        }  
     
        function verifCaptcha(myString){ // idTag 15
            myString = jQuery.trim(myString);
     
            if(myString==''){
                return false;
            }else{
                return true;
            }
        }
     
        /*
         * Gestion des FieldsetErrors
         */
     
        function verifField(){
     
            $.each(tabFieldsRequired, function(index,n){
                var i=0;
                var type=$('#element_id'+n+'-'+i).attr("type");
                var str=$('#element_id'+n+'-'+i).val();
     
                if(type=="checkbox" || type=="radio"){
     
                    var checkStr=false;
                    while(typeof $('#element_id'+n+'-'+i).attr('checked')!=="undefined"){
                        if($('#element_id'+n+'-'+i).attr('checked')==true){checkStr=true;}
                        i++;
                    }
                    if(checkStr==false){
                        $('#errorField_'+n).html(tabErrorFields[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                        nbrErrors++;
                    }else{
                        $('#errorField_'+n).html('').css({"padding":"0px"});
                    }
                }else{
     
                    str = jQuery.trim(str);
     
                    if(str==''){
                        $('#errorField_'+n).html(tabErrorFields[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                        nbrErrors++;
                    }
                    else{
                        if(str!=''){                   
                            $('#errorField_'+n).html('').css({"padding":"0px"});
                        }
                    }
                }
     
                // Gestion du captcha
                var ElemClass=$('#element_id'+n+'-'+i).attr("class");
                if(ElemClass=='formallin_captcha' && !verifCaptcha(str)){
                    $('td#tdCaptcha input').css({"background-color":"FFE6E6"});
                    nbrErrors++;
                }else{
                    $('td#tdCaptcha input').css({"background-color":"fff"});
                }
            });
        }
     
        /*
         * Gestion des FormatErrors
         */
     
        function verifFormat(){
     
            $.each(tabFormatsRequired, function(index,n){
                var i=0;
     
                var ElemClass=$('#element_id'+n+'-'+i).attr("class");
                var ElemValue=$('#element_id'+n+'-'+i).val();
                ElemValue = jQuery.trim(ElemValue);
     
                switch(ElemClass){
     
                case 'formallin_numeric' : if(!verifNumber(ElemValue) && ElemValue!=''){
                    $('#errorFormat_'+n).html(tabErrorFormats[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                    nbrErrors++;
                }else{
                    $('#errorFormat_'+n).html('').css({"padding":"0px"});
                }
                break;
     
                case 'formallin_email' : if(!verifEmail(ElemValue) && ElemValue!=''){
                    $('#errorFormat_'+n).html(tabErrorFormats[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                    nbrErrors++;
                }else{
                    $('#errorFormat_'+n).html('').css({"padding":"0px"});
                }
                break;
     
                case 'formallin_url' : if(!verfifUrl(ElemValue) && ElemValue!=''){
                    $('#errorFormat_'+n).html(tabErrorFormats[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                    nbrErrors++;
                }else{
                    $('#errorFormat_'+n).html('').css({"padding":"0px"});
                }
                break;
     
    //          case 'datepicker' : ;
    //          break;
     
                }
     
     
            });
        }
     
        /*
         * Execution des tests
         */
     
        verifField();
        verifFormat();
     
        /*
         * Evaluation finale
         */
     
        if(nbrErrors==0){
            return true;
        }else{
            return false;
        }
    }</script>
     
            <?php
            switch($lang_id){
     
                case 1 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-zh-CN.js"></script>';
                        break;
     
                case 2 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-ca.js"></script>';
                        break;
     
                case 3 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-da.js"></script>';
                        break;
     
                case 4 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-de.js"></script>';
                        break;
     
                case 5 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-fr.js"></script>';
                        break;
     
                case 6 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-it.js"></script>';
                        break;
     
                case 7 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-pt-BR.js"></script>';
                        break;
     
                case 8 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-ru.js"></script>';
                        break;
     
                case 9 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-es.js"></script>';
                        break;
     
                case 10 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-en-GB.js"></script>';
                        break;
     
                case 11 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-ro.js"></script>';
                        break;
     
                case 12 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-pl.js"></script>';
                        break;
     
                case 13 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-nl.js"></script>';
                        break;
            }
            ?>
     
     
     
     
     
    </head>
    <body>
    <?php define("_TAB_FORMALLEX","formallin_formallex"); ?>
    <?php $sessionFormallinEditor = "W74sbtAurtDHqKSHwsTQL71KinteXLdSi7kjICvY"; ?>
    <?php if( isset($_POST['submit']) ){ // le formulaire a été posté
    $depart = substr(element_id4,0,2);  // 0 ou 1 à vérifier
      if (strpos('93;95;60;62;80;59;02;27;28;76;14;50',$depart) !== false) {
        $email = "adresseA@gmail.com";
        $formName="Devis TEST";
        $emailSubject="Informations transmises par le formulaire";
    } else {
      if( date("d") % 2 == 0 )
        $email="adresseA@gmail.com";// nous sommes un jour pair
      else
        $email="adresseB@gmail.com";// nous sommes un jour impair
        $formName="Devis TEST";
        $emailSubject="Informations transmises par le formulaire";
       }
      ?>
     
    <?php
    //-------------------------------------------------------------------------------------------------------
    /* version  1.3 | author : Leo West | lwest@free.fr
     */
    class Mail{
        var $sendto = array();
        var $acc = array();
        var $abcc = array();
        var $aattach = array();
        var $xheaders = array();
        var $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' );
        var $charset = "utf-8"; /* us-ascii */
        var $ctencoding = "7bit";
        var $receipt = 0;
     
        function Mail(){
            $this->autoCheck( true );
            $this->boundary= "--" . md5( uniqid("myboundary") );
        }
     
        function autoCheck( $bool ){
            if( $bool )
            $this->checkAddress = true;
            else
            $this->checkAddress = false;
        }
     
        function Subject( $subject ){
            $this->xheaders['Subject'] = strtr( $subject, "\r\n" , "  " );
        }
     
        function From( $from ){
            if( ! is_string($from) ) {
                echo "Class Mail: error, From is not a string";
                exit;
            }
            $this->xheaders['From'] = $from;
        }
     
        function ReplyTo( $address ){
            if( ! is_string($address) )
            return false;
            $this->xheaders["Reply-To"] = $address;
        }
     
        function Receipt(){
            $this->receipt = 1;
        }
     
        function To( $to ){
            if( is_array( $to ) )
            $this->sendto= $to;
            else
            $this->sendto[] = $to;
            if( $this->checkAddress == true )
            $this->CheckAdresses( $this->sendto );
        }
     
        function Cc( $cc ){
            if( is_array($cc) )
            $this->acc= $cc;
            else
            $this->acc[]= $cc;
            if( $this->checkAddress == true )
            $this->CheckAdresses( $this->acc );
        }
     
        function Bcc( $bcc ){
            if( is_array($bcc) ) {
                $this->abcc = $bcc;
            } else {
                $this->abcc[]= $bcc;
            }
            if( $this->checkAddress == true )
            $this->CheckAdresses( $this->abcc );
        }
     
        function Body( $body, $charset="" ){
            $this->body = $body;
            if( $charset != "" ) {
                $this->charset = strtolower($charset);
                if( $this->charset != "utf-8" ) /* us-ascii */
                $this->ctencoding = "8bit";
            }
        }
     
        function Organization( $org ){
            if( trim( $org != "" )  )
            $this->xheaders['Organization'] = $org;
        }
     
        function Priority( $priority ){
            if( ! intval( $priority ) )
            return false;
            if( ! isset( $this->priorities[$priority-1]) )
            return false;
            $this->xheaders["X-Priority"] = $this->priorities[$priority-1];
            return true;
        }
     
        function Attach( $filename, $filetype = "", $disposition = "inline" ){
            if( $filetype == "" )
            $filetype = "application/x-unknown-content-type";
            $this->aattach[] = $filename;
            $this->actype[] = $filetype;
            $this->adispo[] = $disposition;
        }
     
        function BuildMail(){
            $this->headers = "";
            if( count($this->acc) > 0 )
            $this->xheaders['CC'] = implode( ", ", $this->acc );
            if( count($this->abcc) > 0 )
            $this->xheaders['BCC'] = implode( ", ", $this->abcc );
            if( $this->receipt ) {
                if( isset($this->xheaders["Reply-To"] ) )
                $this->xheaders["Disposition-Notification-To"] = $this->xheaders["Reply-To"];
                else
                $this->xheaders["Disposition-Notification-To"] = $this->xheaders['From'];
            }
            if( $this->charset != "" ) {
                $this->xheaders["Mime-Version"] = "1.0";
                $this->xheaders["Content-Type"] = "text/plain; charset=$this->charset";
                $this->xheaders["Content-Transfer-Encoding"] = $this->ctencoding;
            }
            $this->xheaders["X-Mailer"] = "Php/libMailv1.3";
            if( count( $this->aattach ) > 0 ) {
                $this->_build_attachement();
            } else {
                $this->fullBody = $this->body;
            }
            reset($this->xheaders);
            while( list( $hdr,$value ) = each( $this->xheaders )  ) {
                if( $hdr != "Subject" )
                $this->headers .= "$hdr: $value\n";
            }
        }
     
        function Send(){
            $this->BuildMail();
            $this->strTo = implode( ", ", $this->sendto );
            $res = @mail( $this->strTo, $this->xheaders['Subject'], $this->fullBody, $this->headers );
        }
     
        function Get(){
            $this->BuildMail();
            $mail = "To: " . $this->strTo . "\n";
            $mail .= $this->headers . "\n";
            $mail .= $this->fullBody;
            return $mail;
        }
     
        function ValidEmail($address){
            if( preg_match( "#.*<(.+)>#", $address, $regs ) ) {
                $address = $regs[1];
            }
            if(preg_match( "#^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$#",$address) )
            return true;
            else
            return false;
        }
     
        function CheckAdresses( $aad ){
            for($i=0;$i< count( $aad); $i++ ) {
                if( ! $this->ValidEmail( $aad[$i]) ) {
                    echo "Class Mail, method Mail : invalid address $aad[$i]";
                    exit;
                }
            }
        }
     
        function _build_attachement(){
            $this->xheaders["Content-Type"] = "multipart/mixed;\n boundary=\"$this->boundary\"";
            $this->fullBody = "This is a multi-part message in MIME format.\n--$this->boundary\n";
            $this->fullBody .= "Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n" . $this->body ."\n";
            $sep= chr(13) . chr(10);
            $ata= array();
            $k=0;
            for( $i=0; $i < count( $this->aattach); $i++ ) {
                $filename = $this->aattach[$i];
                $basename = basename($filename);
                $ctype = $this->actype[$i];  // content-type
                $disposition = $this->adispo[$i];
                if( ! file_exists( $filename) ) {
                    echo "Class Mail, method attach : file $filename can't be found"; exit;
                }
                $subhdr= "--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding: base64\nContent-Disposition: $disposition;\n  filename=\"$basename\"\n";
                $ata[$k++] = $subhdr;
                $linesz= filesize( $filename)+1;
                $fp= fopen( $filename, 'r' );
                $ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
                fclose($fp);
            }
            $this->fullBody .= implode($sep, $ata);
        }
    }
    //-------------------------------------------------------------------------------------------------------
    ?><?php
    $tabGroupeElementsLabel=unserialize(base64_decode($_POST['tabGroupeElementsLabel']));
    $tabLabelText=unserialize(base64_decode($_POST['tabLabelText']));
    $tabErrorFields=unserialize(base64_decode($_POST['tabErrorFields']));
    $tabErrorFormats=unserialize(base64_decode($_POST['tabErrorFormats']));
    $tabShortNames=unserialize(base64_decode($_POST['tabShortNames']));
    $lang_id=array_search($_GET['lang'],$tabShortNames)+1;
    $sys_lang_id=$_POST['sli'];
     
    $lines='IP : '.$_SERVER['SERVER_ADDR'].'<br />'; // collecte de l'ip du visiteur
    $nbrErrors=0;
    $errorsText='';
     
    foreach($tabGroupeElementsLabel as $key=>$tab){
        $tagId=$tab[0];
        $textLabel=$tabLabelText[$key][$lang_id];
        $fieldRequired=$tab[2];
        if($fieldRequired=="yes"){
            switch($tagId){
                case 1 : if(isset($_POST['element_text'][$key])){$val=trim($_POST['element_text'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 2 : if(isset($_POST['element_password'][$key])){$val=trim($_POST['element_password'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 3 : if(isset($_POST['element_numeric'][$key])){$val=trim($_POST['element_numeric'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 4 : if(isset($_POST['element_email'][$key])){$val=trim($_POST['element_email'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 5 : if(isset($_POST['element_url'][$key])){$val=trim($_POST['element_url'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 6 : if(isset($_POST['element_textarea'][$key])){$val=trim($_POST['element_textarea'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 7 : if(isset($_POST['element_checkbox'][$key])){$val=trim($_POST['element_checkbox'][$key][0]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 8 : if(isset($_POST['element_radio'][$key])){$val=trim($_POST['element_radio'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 9 : if(isset($_POST['element_select'][$key])){$val=trim($_POST['element_select'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 10 : if(isset($_POST['element_datepicker'][$key])){$val=trim($_POST['element_datepicker'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 11 : if(isset($_POST['element_file'][$key])){$val=trim($_POST['element_file'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 15 : if(isset($_POST['element_captcha'][$key])){$val=trim($_POST['element_captcha'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.=$tabErrorFields[$key][$lang_id]."<br />";} break;
            }
        }
    }
     
     
    if($nbrErrors==0){
     
        foreach($tabGroupeElementsLabel as $key=>$tab){
     
            foreach($tab as $tagId=>$textLabel){
                $tagId=$tab[0];
                $textLabel=$tabLabelText[$key][$lang_id];
            }
     
            if($tagId==3){
                if (!is_numeric($_POST['element_numeric'][$key]) && !empty($_POST['element_numeric'][$key])){
                    $nbrErrors++;
                    $errorsText.='"'.$textLabel.'" : ';
                    $errorsText.=$tabErrorFormats[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
            elseif($tagId==4){
                if (!preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['element_email'][$key]) && !empty($_POST['element_email'][$key])){
                    $nbrErrors++;
                    $errorsText.='"'.$textLabel.'" : ';
                    $errorsText.=$tabErrorFormats[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
            elseif($tagId==5){
                if(strpos($_POST['element_url'][$key], 'http://') === FALSE && !empty($_POST['element_url'][$key])){
                    $nbrErrors++;
                    $errorsText.='"'.$textLabel.'" : ';
                    $errorsText.=$tabErrorFormats[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
            elseif($tagId==10){
            }
            elseif($tagId==11){
     
                //print_r($tabExtension);
     
            }
            elseif($tagId==15){
                if( isset($_SESSION['security_code']) && ($_SESSION['security_code'] != $_POST['element_captcha'][$key])) {
                    $nbrErrors++;
                    $errorsText.=$tabErrorFields[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
        }
     
     
        if($nbrErrors==0){
     
            /*
             * Récupération des Labels et des champs pour l'email envoyé au contact administratif
             */
     
            foreach($tabGroupeElementsLabel as $key=>$tab){
     
                foreach($tab as $tagId=>$textLabel){
                    $tagId=$tab[0];
                    $textLabel=$tab[1];
                }
     
                if($tagId!=15){$lines.=$textLabel.' : ';}
     
                switch($tagId){
                    case 1 : if(isset($_POST['element_text'][$key])){$lines.=trim($_POST['element_text'][$key]);} break;
                    case 2 : if(isset($_POST['element_password'][$key])){$lines.=trim($_POST['element_password'][$key]);} break;
                    case 3 : if(isset($_POST['element_numeric'][$key])){$lines.=trim($_POST['element_numeric'][$key]);} break;
                    case 4 : if(isset($_POST['element_email'][$key])){$lines.=trim($_POST['element_email'][$key]);} break;
                    case 5 : if(isset($_POST['element_url'][$key])){$lines.=trim($_POST['element_url'][$key]);} break;
                    case 6 : if(isset($_POST['element_textarea'][$key])){$lines.=trim($_POST['element_textarea'][$key]);} break;
                    case 7 : if(isset($_POST['element_checkbox'][$key]) && !empty($_POST['element_checkbox'][$key])){foreach($_POST['element_checkbox'][$key] as $key=>$value){$lines.=trim($value).", ";}} break;
                    case 8 : if(isset($_POST['element_radio'][$key])){$lines.=trim($_POST['element_radio'][$key]);} break;
                    case 9 : if(isset($_POST['element_select'][$key])){$lines.=trim($_POST['element_select'][$key]);} break;
                    case 10 : if(isset($_POST['element_datepicker'][$key])){$lines.=trim($_POST['element_datepicker'][$key]);} break;
                    case 11 : if(isset($_POST['element_file'][$key])){$lines.=trim($_POST['element_file'][$key]);} break;
                }
     
                $lines.="<br /><br />";
            }
     
            /*
             * Envoi de l'email
             */
     
            $lines=str_replace("<br />","\n",$lines);
     
            $em=explode(";",$email);
     
            foreach($em as $e){ // boucle pour transmettre la soumission du formulaire à tous les destinataires concernés
     
                // construction de l'email
                $subject=$emailSubject.' ['.$formName.']';
                $tab=explode("@",$e);
                $ndd=$tab[1];
                $expediteur="no-reply@$ndd";
     
                $m= new Mail;
                $m->From($expediteur);
                $m->To($e);
                $m->Subject($subject);
                $m->Body(stripslashes($lines));
                $m->Priority(1);
     
                // envoie de l'email
                $m->Send();
            }
     
            include_once("../../connectors/formallin_connector_bddAcces.php"); /* FORMALLIN */
     
            // connexion
            global $db;
            include("../../db.php");
            $db=new DB;
            $db->_connectar();
     
            include_once('../classes/FA_Sql.class.php');
            include_once('../classes/FA_Formallex.class.php');
     
            function fa_inDB($string){
                return mysql_real_escape_string(stripslashes($string));
            }
     
            $formallex = new FA_Formallex();
            $formallex->setSessionFormallinEditor($sessionFormallinEditor);
            $formallex->setContent(stripslashes($lines));
            $formallex->createFormallex();
     
            $db->_desconnectar();       
        }
    }
    ?><?php } ?><?php if(in_array($lang_id,$tab_langIds)){ ?>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?lang=<?php echo $_GET['lang'];?>" onSubmit="return validForm();">
    <fieldset>
    <legend><?php echo $tabFieldsetLegends[$lang_id];?></legend>
    <table>
    <?php
    $tabLabelText[0][5]="Code postal";
    ?>
    <script type="text/javascript">
    tabErrorFormats[0] = new Array();
    tabErrorFormats[0][5]="le format n'est pas respecté";
    tabFormatsRequired.push(0);
    </script>
    <tr>
    <td><label for="element_id0-0"><?php echo $tabLabelText[0][$lang_id];?></label></td>
    <td><input type="text" size="20" maxlength="45" class="formallin_numeric" name="element_numeric[0]" id="element_id0-0"/></td>
    </tr>
    <tr><td></td><td><div class="errorMessage" id="error_0"><div class="errorField" id="errorField_0"></div><div class="errorFormat" id="errorFormat_0"></div></div></td></tr><tr><td></td><td></td></tr>
    <input type="hidden" name="tabGroupeElementsLabel" value="YToxOntpOjA7YTozOntpOjA7czoxOiIzIjtpOjE7czoxMToiQ29kZSBwb3N0YWwiO2k6MjtzOjI6Im5vIjt9fQ==" />
    <input type="hidden" name="tabErrorFields" value="czowOiIiOw==" />
    <input type="hidden" name="tabErrorFormats" value="YToxOntpOjA7YToxOntpOjU7czoyOToibGUgZm9ybWF0IG4nZXN0IHBhcyByZXNwZWN0w6kiO319" />
    <input type="hidden" name="tabShortNames" value="<?php echo base64_encode(serialize($tabShortNames));?>" />
    <input type="hidden" name="tabLabelText" value="<?php echo base64_encode(serialize($tabLabelText));?>" />
    <input type="hidden" name="sli" value="5" />
    <tr><td>&nbsp;</td><td><?php if(isset($_POST['submit']) && $nbrErrors>0){ echo '<div class="submitError"><br />'.$errorsText.'<br /></div>'; }?></td></tr>
    <?php
    $tabAttributesValues_1['value'][5]="valider";
    ?>
    <tr><td><input id="element_id1-0" name="submit" type="submit" class="formallin_submit"  value="<?php echo $tabAttributesValues_1['value'][$lang_id];?>"  /> -
    <?php
    $tabAttributesValues_2['value'][5]="effacer";
    ?>
    <input id="element_id2-0" name="reset" type="reset" class="formallin_reset"  value="<?php echo $tabAttributesValues_2['value'][$lang_id];?>"  /></td></tr>
    </table>
    </fieldset>
    </form>
    <?php
    if(isset($_POST['submit']) && $nbrErrors==0){
    $lang = $_GET['lang'];
    // si le message a bien été transmis
    $tabLangSuccess['fr'] = "Les informations que vous avez saisies ont bien été transmises. Nous vous en remercions."; // France
     
    // si le message n'a pu être transmis
    $tabLangFailure['fr'] = "Les informations que vous avez saisies n'ont pu être transmises, veuillez réessayer ultérieurement."; // France
    $messageText = $tabLangSuccess[$lang];
     
    $successMessage=<<<msn
    <script type="text/javascript">
    var SUCCESS_MESSAGE="$messageText";
    </script>
    msn;
    echo $successMessage;
    ?>
    <script type="text/javascript">
    $(document).ready(function(){
     
        var bgColor = $('fieldset').css('backgroundColor');
     
        // effet lumineux et confirmation de soumission du formulaire
        $('fieldset').animate({backgroundColor:"#9ee19a", opacity:0},500)
        .animate({backgroundColor:bgColor,opacity:1},500 )
        .animate({opacity:0},500 )
        .queue(function(){
            $('fieldset').html('<div id="success">'+SUCCESS_MESSAGE+'</div>').css({opacity:1});
            $('#success').hide().fadeIn('slow');
        })
    });
    </script>
    <?php
    };
    ?>
    <?php } ?>
    </body>
    </html>
    Bien amicalement

  2. #2
    Expert confirmé
    Avatar de laurentSc
    Homme Profil pro
    Webmaster débutant perpétuel !
    Inscrit en
    Octobre 2006
    Messages
    10 470
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmaster débutant perpétuel !
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2006
    Messages : 10 470
    Points : 5 828
    Points
    5 828
    Billets dans le blog
    1
    Par défaut
    C'est sûr que si tu passes rien à in_array, ça va pas marcher. Un truc du genre in_array($val,$tab_cp)...

    En outre, la condition if(isset(!empty($tabLabelText[0]['element_id0-0'])) ne colle pas : !empty... est un booléen et isset attend une variable...

    Et on ne sait pas ce que contient cette variable ($tabLabelText[0]['element_id0-0']) ; tu n'en dis pas assez...

  3. #3
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2013
    Messages
    55
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 55
    Points : 27
    Points
    27
    Par défaut
    Bonsoir Laurent

    Le code n'est pas juste, car c'est une histoire d'adaptation!

    La condition qui fonctionne individuellement pour les jours pairs et inpairs
    c'est celle-ci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <?php if( isset($_POST['submit']) ){ // le formulaire a été posté
      if( date("d") % 2 == 0 ) // nous sommes un jour pair
        $email="iadresseA@gmail.com";
      else
        $email="adresseB@gmail.com";
      // informations identiques quelque soit le jour
      $formName="Devis campagne N°1"; 
      $emailSubject="Informations transmises par le formulaire";
      ?>
    La recette pour le code postal c'est celle-ci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    <?php
     
    $tab_cp=array('93', '95', '60', '62' , '80' , '59' , '02' , '27' , '28' , '76' ,  '14' , '50'); // Tableaux des codes postaux
    $select_email=0;
     
    if(isset(!empty($_POST['code_postal']))
    {
        $cp=$_POST['code_postal'];
        $int_cp = intval(substr($cp,0,2)); //Troncature du code postal pour ne garder que les 2 premiers caracteres et transforme en entier
     
        foreach($cp as $code => $var){
        	if($int_cp == $var){
        	    $select_email=1; // Si code postal est dans la liste on choisi cet email
        	}
       }
    }
     
    if($select_email == '1'){
    	echo 'email1'; //Mettre le code d'envoi email
    }else
    {
    	echo 'email2'; //Mettre le code d'envoi email
    }
     
    ?>
    Mais mon problème c'est pour l'adapter en mixant les deux conditions sur mon fichier ci-dessous entre les lignes 416 et 428:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
    <title>Untitled Document</title>
    </head>
     
    <body>
    <?php session_start(); header("Content-Type: text/html; charset=UTF-8"); ?>
    <?php
    /*
     * Formulaire généré par formallin v2.3.0
     * Auteur : Grégory Toucas
     * http://www.atomestudio.com / contact@atomestudio.com
     * Soutenu par l'agence web IDEEMATIC : http://www.ideematic.com
     *
     * Programme sous licence GPL:
     * http://www.gnu.org/licenses/gpl.html
     *
    */
    echo '
    <!--
    Formulaire généré par formallin v2.3.0
    Auteur : Grégory Toucas
    http://www.atomestudio.com / contact@atomestudio.com
    Soutenu par l agence web IDEEMATIC : http://www.ideematic.com
     
    Programme sous licence GPL:
    http://www.gnu.org/licenses/gpl.html
    -->
    ';
    ?>
    <?php
    $tabFieldsetLegends[5]="Titre";
    ?>
    <?php
    // Ensemble de fonctions
    function fa_phpToJs($var) {
        if (is_array($var)) {
            $res = "[";
            $array = array();
            foreach ($var as $a_var) {
                $array[] = fa_phpToJs($a_var);
            }
            return "[" . join(",", $array) . "]";
        }
        elseif (is_bool($var)) {
            return $var ? "true" : "false";
        }
        elseif (is_int($var) || is_integer($var) || is_double($var) || is_float($var)) {
            return $var;
        }
        elseif (is_string($var)) {
            return "\"" . addslashes(stripslashes($var)) . "\"";
        }
        // autres cas: objets, on ne les gère pas
        return FALSE;
    }
     
    function fa_str_post($string){
        if (isset($_POST[$string])) { $return_string = trim($_POST[$string]); } else { $return_string = ""; }
        return $return_string;
    }
    ?>
            <script type="text/javascript">
            var tabErrorFields=new Array();
            var tabErrorFormats=new Array();
            var tabFieldsRequired=new Array();
            var tabFormatsRequired=new Array();
            </script><?php $list_langIds="5"; $tab_langIds=explode(",",$list_langIds); ?>
    <?php
    $tabShortNames[0]="zh";
    $tabShortNames[1]="ca";
    $tabShortNames[2]="da";
    $tabShortNames[3]="de";
    $tabShortNames[4]="fr";
    $tabShortNames[5]="it";
    $tabShortNames[6]="pt";
    $tabShortNames[7]="ru";
    $tabShortNames[8]="es";
    $tabShortNames[9]="en";
    $tabShortNames[10]="ro";
    $tabShortNames[11]="pl";
    $tabShortNames[12]="nl";
    ?>
    <?php if(is_array($tabShortNames)){ $lang_id=array_search($_GET['lang'],$tabShortNames)+1; }else{ $lang_id=""; }?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $_GET['lang'];?>" xml:lang="<?php echo $_GET['lang'];?>">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title></title>
    <script type="text/javascript">var langId="<?php echo $lang_id;?>"; var issetCaptcha=false;</script>
    <style type="text/css">
     
            body {
                margin: 0px; padding: 0px; width:100%;
                font-family: "Trebuchet MS",arial,verdana, serif;
                font-weight: normal; font-size: 10px; color: #48566e;  text-align: left; /* line-height: 1.3em; */
                overflow-x: hidden;
                /* overflow-y: hidden; */
            }
     
            span.span_chbx_radio { float:left; width:200px; }
     
            input[type=submit] { opacity: 0.8; padding:5px; -moz-border-radius:5px; -webkit-border-radius:5px; -khtml-border-radius:5px; border:1px solid #E2E2E7; background-color:#8BA9DC; color:#ffffff; cursor: pointer;}
            input[type=reset] { opacity: 0.8; padding:5px; -moz-border-radius:5px; -webkit-border-radius:5px; -khtml-border-radius:5px; border:1px solid #E2E2E7; background-color:#f5f5f5; color:#333333; cursor: pointer;}
     
            input[type=submit]:hover, input[type=reset]:hover { opacity:0.5; }
     
            a { color:#48566e; }
     
            input[type=text], input[type=password] {
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;
                border:1px solid #8BA9DC;
                background-color:#ffffff;
                color:#48566e;
            }
     
            textarea {
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;
                border:1px solid #8BA9DC;
                background-color:#ffffff;
                color:#48566e; 
            }
     
            fieldset {
                border:1px solid #8BA9DC;
                background-color:#ffffff;
                margin: 5px;
                min-height: 100px;
                -moz-border-radius:5px;
                -webkit-border-radius:5px;
                -khtml-border-radius:5px;
            }
     
            legend {
                border:1px solid #ffffff;
                background-color: #ffffff;
                padding:4px;
                color:#8BA9DC;
                -moz-border-radius:4px;
                -webkit-border-radius:4px;
                -khtml-border-radius:4px;
                font-size:1.2em;
            }
     
            .errorMessage {
                font-size: 0.8em;
                color:#cc0000;  
            }
     
            .errorField, .errorFormat {
                background-color: #ffe6e6;
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;  
            }
     
            .submitError {
                padding:5px;
                color:#cc0000;
                border: 1px solid #cc0000;
                background-color: #ffe6e6;
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;
            }
     
            label, .span_chbx_radio {
                color:#48566e;
                font-size: 0.8em;
            }
     
            .obligatoryField {
                color:#cc0000;
                font-size: 1.2em;
            }
     
            #success {
                padding: 20px;
                font-size: 16px;
            }      
            </style>
    <link rel="stylesheet" type="text/css" href="http://jquery-ui.googlecode.com/svn/tags/latest/themes/base/jquery.ui.all.css" />
    <script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="../js/jquery-ui.min.js" type="text/javascript"></script>
    <script src="../js/jquery.ui.datepicker.min.js"></script>
    <script type="text/javascript">
    $(function(){ $(".datepicker").datepicker({changeMonth: true,changeYear: true}); });
    </script>
    <script type="text/javascript">function validForm(){
     
        /*
         * Initialisation des variables
         */
     
        var nbrErrors=0;
     
     
        /*
         * Fonctions de vérification des formatages
         */
     
        function verifNumber(myString){ // idTag 3 
            if(isNaN(myString)){ return false; }else { return true; }  
        }
     
     
        function verifEmail(myString){ // idTag 4
     
            var reg= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
     
            if(reg.test(myString)==true){
                return true; // adresse valide
            }
            else{
                return false; // adresse non valide
            }
        }
     
     
        function verfifUrl(myString){ // idTag 5
     
            var reg= /(http):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
     
            if(reg.test(myString)==true){
                return true; // adresse valide
            }
            else{
                return false; // adresse non valide
            }
     
        }  
     
        function verifCaptcha(myString){ // idTag 15
            myString = jQuery.trim(myString);
     
            if(myString==''){
                return false;
            }else{
                return true;
            }
        }
     
        /*
         * Gestion des FieldsetErrors
         */
     
        function verifField(){
     
            $.each(tabFieldsRequired, function(index,n){
                var i=0;
                var type=$('#element_id'+n+'-'+i).attr("type");
                var str=$('#element_id'+n+'-'+i).val();
     
                if(type=="checkbox" || type=="radio"){
     
                    var checkStr=false;
                    while(typeof $('#element_id'+n+'-'+i).attr('checked')!=="undefined"){
                        if($('#element_id'+n+'-'+i).attr('checked')==true){checkStr=true;}
                        i++;
                    }
                    if(checkStr==false){
                        $('#errorField_'+n).html(tabErrorFields[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                        nbrErrors++;
                    }else{
                        $('#errorField_'+n).html('').css({"padding":"0px"});
                    }
                }else{
     
                    str = jQuery.trim(str);
     
                    if(str==''){
                        $('#errorField_'+n).html(tabErrorFields[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                        nbrErrors++;
                    }
                    else{
                        if(str!=''){                   
                            $('#errorField_'+n).html('').css({"padding":"0px"});
                        }
                    }
                }
     
                // Gestion du captcha
                var ElemClass=$('#element_id'+n+'-'+i).attr("class");
                if(ElemClass=='formallin_captcha' && !verifCaptcha(str)){
                    $('td#tdCaptcha input').css({"background-color":"FFE6E6"});
                    nbrErrors++;
                }else{
                    $('td#tdCaptcha input').css({"background-color":"fff"});
                }
            });
        }
     
        /*
         * Gestion des FormatErrors
         */
     
        function verifFormat(){
     
            $.each(tabFormatsRequired, function(index,n){
                var i=0;
     
                var ElemClass=$('#element_id'+n+'-'+i).attr("class");
                var ElemValue=$('#element_id'+n+'-'+i).val();
                ElemValue = jQuery.trim(ElemValue);
     
                switch(ElemClass){
     
                case 'formallin_numeric' : if(!verifNumber(ElemValue) && ElemValue!=''){
                    $('#errorFormat_'+n).html(tabErrorFormats[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                    nbrErrors++;
                }else{
                    $('#errorFormat_'+n).html('').css({"padding":"0px"});
                }
                break;
     
                case 'formallin_email' : if(!verifEmail(ElemValue) && ElemValue!=''){
                    $('#errorFormat_'+n).html(tabErrorFormats[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                    nbrErrors++;
                }else{
                    $('#errorFormat_'+n).html('').css({"padding":"0px"});
                }
                break;
     
                case 'formallin_url' : if(!verfifUrl(ElemValue) && ElemValue!=''){
                    $('#errorFormat_'+n).html(tabErrorFormats[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                    nbrErrors++;
                }else{
                    $('#errorFormat_'+n).html('').css({"padding":"0px"});
                }
                break;
     
    //          case 'datepicker' : ;
    //          break;
     
                }
     
     
            });
        }
     
        /*
         * Execution des tests
         */
     
        verifField();
        verifFormat();
     
        /*
         * Evaluation finale
         */
     
        if(nbrErrors==0){
            return true;
        }else{
            return false;
        }
    }</script>
     
            <?php
            switch($lang_id){
     
                case 1 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-zh-CN.js"></script>';
                        break;
     
                case 2 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-ca.js"></script>';
                        break;
     
                case 3 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-da.js"></script>';
                        break;
     
                case 4 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-de.js"></script>';
                        break;
     
                case 5 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-fr.js"></script>';
                        break;
     
                case 6 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-it.js"></script>';
                        break;
     
                case 7 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-pt-BR.js"></script>';
                        break;
     
                case 8 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-ru.js"></script>';
                        break;
     
                case 9 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-es.js"></script>';
                        break;
     
                case 10 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-en-GB.js"></script>';
                        break;
     
                case 11 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-ro.js"></script>';
                        break;
     
                case 12 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-pl.js"></script>';
                        break;
     
                case 13 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-nl.js"></script>';
                        break;
            }
            ?>
     
     
     
     
     
    </head>
    <body>
    <?php define("_TAB_FORMALLEX","formallin_formallex"); ?>
    <?php $sessionFormallinEditor = "W74sbtAurtDHqKSHwsTQL71KinteXLdSi7kjICvY"; ?>
    <?php if( isset($_POST['submit']) ){ // le formulaire a été posté
      if( date("d") % 2 == 0 ) // nous sommes un jour pair
        $email="adresseA@gmail.com";
      else
        $email="adresseB@gmail.com";
      // informations identiques quelque soit le jour
      $formName="Devis campagne N°1"; 
      $emailSubject="Informations transmises par le formulaire";
      ?>
     
    <?php
    //-------------------------------------------------------------------------------------------------------
    /* version  1.3 | author : Leo West | lwest@free.fr
     */
    class Mail{
        var $sendto = array();
        var $acc = array();
        var $abcc = array();
        var $aattach = array();
        var $xheaders = array();
        var $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' );
        var $charset = "utf-8"; /* us-ascii */
        var $ctencoding = "7bit";
        var $receipt = 0;
     
        function Mail(){
            $this->autoCheck( true );
            $this->boundary= "--" . md5( uniqid("myboundary") );
        }
     
        function autoCheck( $bool ){
            if( $bool )
            $this->checkAddress = true;
            else
            $this->checkAddress = false;
        }
     
        function Subject( $subject ){
            $this->xheaders['Subject'] = strtr( $subject, "\r\n" , "  " );
        }
     
        function From( $from ){
            if( ! is_string($from) ) {
                echo "Class Mail: error, From is not a string";
                exit;
            }
            $this->xheaders['From'] = $from;
        }
     
        function ReplyTo( $address ){
            if( ! is_string($address) )
            return false;
            $this->xheaders["Reply-To"] = $address;
        }
     
        function Receipt(){
            $this->receipt = 1;
        }
     
        function To( $to ){
            if( is_array( $to ) )
            $this->sendto= $to;
            else
            $this->sendto[] = $to;
            if( $this->checkAddress == true )
            $this->CheckAdresses( $this->sendto );
        }
     
        function Cc( $cc ){
            if( is_array($cc) )
            $this->acc= $cc;
            else
            $this->acc[]= $cc;
            if( $this->checkAddress == true )
            $this->CheckAdresses( $this->acc );
        }
     
        function Bcc( $bcc ){
            if( is_array($bcc) ) {
                $this->abcc = $bcc;
            } else {
                $this->abcc[]= $bcc;
            }
            if( $this->checkAddress == true )
            $this->CheckAdresses( $this->abcc );
        }
     
        function Body( $body, $charset="" ){
            $this->body = $body;
            if( $charset != "" ) {
                $this->charset = strtolower($charset);
                if( $this->charset != "utf-8" ) /* us-ascii */
                $this->ctencoding = "8bit";
            }
        }
     
        function Organization( $org ){
            if( trim( $org != "" )  )
            $this->xheaders['Organization'] = $org;
        }
     
        function Priority( $priority ){
            if( ! intval( $priority ) )
            return false;
            if( ! isset( $this->priorities[$priority-1]) )
            return false;
            $this->xheaders["X-Priority"] = $this->priorities[$priority-1];
            return true;
        }
     
        function Attach( $filename, $filetype = "", $disposition = "inline" ){
            if( $filetype == "" )
            $filetype = "application/x-unknown-content-type";
            $this->aattach[] = $filename;
            $this->actype[] = $filetype;
            $this->adispo[] = $disposition;
        }
     
        function BuildMail(){
            $this->headers = "";
            if( count($this->acc) > 0 )
            $this->xheaders['CC'] = implode( ", ", $this->acc );
            if( count($this->abcc) > 0 )
            $this->xheaders['BCC'] = implode( ", ", $this->abcc );
            if( $this->receipt ) {
                if( isset($this->xheaders["Reply-To"] ) )
                $this->xheaders["Disposition-Notification-To"] = $this->xheaders["Reply-To"];
                else
                $this->xheaders["Disposition-Notification-To"] = $this->xheaders['From'];
            }
            if( $this->charset != "" ) {
                $this->xheaders["Mime-Version"] = "1.0";
                $this->xheaders["Content-Type"] = "text/plain; charset=$this->charset";
                $this->xheaders["Content-Transfer-Encoding"] = $this->ctencoding;
            }
            $this->xheaders["X-Mailer"] = "Php/libMailv1.3";
            if( count( $this->aattach ) > 0 ) {
                $this->_build_attachement();
            } else {
                $this->fullBody = $this->body;
            }
            reset($this->xheaders);
            while( list( $hdr,$value ) = each( $this->xheaders )  ) {
                if( $hdr != "Subject" )
                $this->headers .= "$hdr: $value\n";
            }
        }
     
        function Send(){
            $this->BuildMail();
            $this->strTo = implode( ", ", $this->sendto );
            $res = @mail( $this->strTo, $this->xheaders['Subject'], $this->fullBody, $this->headers );
        }
     
        function Get(){
            $this->BuildMail();
            $mail = "To: " . $this->strTo . "\n";
            $mail .= $this->headers . "\n";
            $mail .= $this->fullBody;
            return $mail;
        }
     
        function ValidEmail($address){
            if( preg_match( "#.*<(.+)>#", $address, $regs ) ) {
                $address = $regs[1];
            }
            if(preg_match( "#^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$#",$address) )
            return true;
            else
            return false;
        }
     
        function CheckAdresses( $aad ){
            for($i=0;$i< count( $aad); $i++ ) {
                if( ! $this->ValidEmail( $aad[$i]) ) {
                    echo "Class Mail, method Mail : invalid address $aad[$i]";
                    exit;
                }
            }
        }
     
        function _build_attachement(){
            $this->xheaders["Content-Type"] = "multipart/mixed;\n boundary=\"$this->boundary\"";
            $this->fullBody = "This is a multi-part message in MIME format.\n--$this->boundary\n";
            $this->fullBody .= "Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n" . $this->body ."\n";
            $sep= chr(13) . chr(10);
            $ata= array();
            $k=0;
            for( $i=0; $i < count( $this->aattach); $i++ ) {
                $filename = $this->aattach[$i];
                $basename = basename($filename);
                $ctype = $this->actype[$i];  // content-type
                $disposition = $this->adispo[$i];
                if( ! file_exists( $filename) ) {
                    echo "Class Mail, method attach : file $filename can't be found"; exit;
                }
                $subhdr= "--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding: base64\nContent-Disposition: $disposition;\n  filename=\"$basename\"\n";
                $ata[$k++] = $subhdr;
                $linesz= filesize( $filename)+1;
                $fp= fopen( $filename, 'r' );
                $ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
                fclose($fp);
            }
            $this->fullBody .= implode($sep, $ata);
        }
    }
    //-------------------------------------------------------------------------------------------------------
    ?><?php
    $tabGroupeElementsLabel=unserialize(base64_decode($_POST['tabGroupeElementsLabel']));
    $tabLabelText=unserialize(base64_decode($_POST['tabLabelText']));
    $tabErrorFields=unserialize(base64_decode($_POST['tabErrorFields']));
    $tabErrorFormats=unserialize(base64_decode($_POST['tabErrorFormats']));
    $tabShortNames=unserialize(base64_decode($_POST['tabShortNames']));
    $lang_id=array_search($_GET['lang'],$tabShortNames)+1;
    $sys_lang_id=$_POST['sli'];
     
    $lines='IP : '.$_SERVER['SERVER_ADDR'].'<br />'; // collecte de l'ip du visiteur
    $nbrErrors=0;
    $errorsText='';
     
    foreach($tabGroupeElementsLabel as $key=>$tab){
        $tagId=$tab[0];
        $textLabel=$tabLabelText[$key][$lang_id];
        $fieldRequired=$tab[2];
        if($fieldRequired=="yes"){
            switch($tagId){
                case 1 : if(isset($_POST['element_text'][$key])){$val=trim($_POST['element_text'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 2 : if(isset($_POST['element_password'][$key])){$val=trim($_POST['element_password'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 3 : if(isset($_POST['element_numeric'][$key])){$val=trim($_POST['element_numeric'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 4 : if(isset($_POST['element_email'][$key])){$val=trim($_POST['element_email'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 5 : if(isset($_POST['element_url'][$key])){$val=trim($_POST['element_url'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 6 : if(isset($_POST['element_textarea'][$key])){$val=trim($_POST['element_textarea'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 7 : if(isset($_POST['element_checkbox'][$key])){$val=trim($_POST['element_checkbox'][$key][0]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 8 : if(isset($_POST['element_radio'][$key])){$val=trim($_POST['element_radio'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 9 : if(isset($_POST['element_select'][$key])){$val=trim($_POST['element_select'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 10 : if(isset($_POST['element_datepicker'][$key])){$val=trim($_POST['element_datepicker'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 11 : if(isset($_POST['element_file'][$key])){$val=trim($_POST['element_file'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 15 : if(isset($_POST['element_captcha'][$key])){$val=trim($_POST['element_captcha'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.=$tabErrorFields[$key][$lang_id]."<br />";} break;
            }
        }
    }
     
     
    if($nbrErrors==0){
     
        foreach($tabGroupeElementsLabel as $key=>$tab){
     
            foreach($tab as $tagId=>$textLabel){
                $tagId=$tab[0];
                $textLabel=$tabLabelText[$key][$lang_id];
            }
     
            if($tagId==3){
                if (!is_numeric($_POST['element_numeric'][$key]) && !empty($_POST['element_numeric'][$key])){
                    $nbrErrors++;
                    $errorsText.='"'.$textLabel.'" : ';
                    $errorsText.=$tabErrorFormats[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
            elseif($tagId==4){
                if (!preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['element_email'][$key]) && !empty($_POST['element_email'][$key])){
                    $nbrErrors++;
                    $errorsText.='"'.$textLabel.'" : ';
                    $errorsText.=$tabErrorFormats[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
            elseif($tagId==5){
                if(strpos($_POST['element_url'][$key], 'http://') === FALSE && !empty($_POST['element_url'][$key])){
                    $nbrErrors++;
                    $errorsText.='"'.$textLabel.'" : ';
                    $errorsText.=$tabErrorFormats[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
            elseif($tagId==10){
            }
            elseif($tagId==11){
     
                //print_r($tabExtension);
     
            }
            elseif($tagId==15){
                if( isset($_SESSION['security_code']) && ($_SESSION['security_code'] != $_POST['element_captcha'][$key])) {
                    $nbrErrors++;
                    $errorsText.=$tabErrorFields[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
        }
     
     
        if($nbrErrors==0){
     
            /*
             * Récupération des Labels et des champs pour l'email envoyé au contact administratif
             */
     
            foreach($tabGroupeElementsLabel as $key=>$tab){
     
                foreach($tab as $tagId=>$textLabel){
                    $tagId=$tab[0];
                    $textLabel=$tab[1];
                }
     
                if($tagId!=15){$lines.=$textLabel.' : ';}
     
                switch($tagId){
                    case 1 : if(isset($_POST['element_text'][$key])){$lines.=trim($_POST['element_text'][$key]);} break;
                    case 2 : if(isset($_POST['element_password'][$key])){$lines.=trim($_POST['element_password'][$key]);} break;
                    case 3 : if(isset($_POST['element_numeric'][$key])){$lines.=trim($_POST['element_numeric'][$key]);} break;
                    case 4 : if(isset($_POST['element_email'][$key])){$lines.=trim($_POST['element_email'][$key]);} break;
                    case 5 : if(isset($_POST['element_url'][$key])){$lines.=trim($_POST['element_url'][$key]);} break;
                    case 6 : if(isset($_POST['element_textarea'][$key])){$lines.=trim($_POST['element_textarea'][$key]);} break;
                    case 7 : if(isset($_POST['element_checkbox'][$key]) && !empty($_POST['element_checkbox'][$key])){foreach($_POST['element_checkbox'][$key] as $key=>$value){$lines.=trim($value).", ";}} break;
                    case 8 : if(isset($_POST['element_radio'][$key])){$lines.=trim($_POST['element_radio'][$key]);} break;
                    case 9 : if(isset($_POST['element_select'][$key])){$lines.=trim($_POST['element_select'][$key]);} break;
                    case 10 : if(isset($_POST['element_datepicker'][$key])){$lines.=trim($_POST['element_datepicker'][$key]);} break;
                    case 11 : if(isset($_POST['element_file'][$key])){$lines.=trim($_POST['element_file'][$key]);} break;
                }
     
                $lines.="<br /><br />";
            }
     
            /*
             * Envoi de l'email
             */
     
            $lines=str_replace("<br />","\n",$lines);
     
            $em=explode(";",$email);
     
            foreach($em as $e){ // boucle pour transmettre la soumission du formulaire à tous les destinataires concernés
     
                // construction de l'email
                $subject=$emailSubject.' ['.$formName.']';
                $tab=explode("@",$e);
                $ndd=$tab[1];
                $expediteur="no-reply@$ndd";
     
                $m= new Mail;
                $m->From($expediteur);
                $m->To($e);
                $m->Subject($subject);
                $m->Body(stripslashes($lines));
                $m->Priority(1);
     
                // envoie de l'email
                $m->Send();
            }
     
            include_once("../../connectors/formallin_connector_bddAcces.php"); /* FORMALLIN */
     
            // connexion
            global $db;
            include("../../db.php");
            $db=new DB;
            $db->_connectar();
     
            include_once('../classes/FA_Sql.class.php');
            include_once('../classes/FA_Formallex.class.php');
     
            function fa_inDB($string){
                return mysql_real_escape_string(stripslashes($string));
            }
     
            $formallex = new FA_Formallex();
            $formallex->setSessionFormallinEditor($sessionFormallinEditor);
            $formallex->setContent(stripslashes($lines));
            $formallex->createFormallex();
     
            $db->_desconnectar();       
        }
    }
    ?><?php } ?><?php if(in_array($lang_id,$tab_langIds)){ ?>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?lang=<?php echo $_GET['lang'];?>" onSubmit="return validForm();">
    <fieldset>
    <legend><?php echo $tabFieldsetLegends[$lang_id];?></legend>
    <table>
    <?php
    $tabLabelText[0][5]="Code postal";
    ?>
    <script type="text/javascript">
    tabErrorFormats[0] = new Array();
    tabErrorFormats[0][5]="le format n'est pas respecté";
    tabFormatsRequired.push(0);
    </script>
    <tr>
    <td><label for="element_id0-0"><?php echo $tabLabelText[0][$lang_id];?></label></td>
    <td><input type="text" size="20" maxlength="45" class="formallin_numeric" name="element_numeric[0]" id="element_id0-0"/></td>
    </tr>
    <tr><td></td><td><div class="errorMessage" id="error_0"><div class="errorField" id="errorField_0"></div><div class="errorFormat" id="errorFormat_0"></div></div></td></tr><tr><td></td><td></td></tr>
    <input type="hidden" name="tabGroupeElementsLabel" value="YToxOntpOjA7YTozOntpOjA7czoxOiIzIjtpOjE7czoxMToiQ29kZSBwb3N0YWwiO2k6MjtzOjI6Im5vIjt9fQ==" />
    <input type="hidden" name="tabErrorFields" value="czowOiIiOw==" />
    <input type="hidden" name="tabErrorFormats" value="YToxOntpOjA7YToxOntpOjU7czoyOToibGUgZm9ybWF0IG4nZXN0IHBhcyByZXNwZWN0w6kiO319" />
    <input type="hidden" name="tabShortNames" value="<?php echo base64_encode(serialize($tabShortNames));?>" />
    <input type="hidden" name="tabLabelText" value="<?php echo base64_encode(serialize($tabLabelText));?>" />
    <input type="hidden" name="sli" value="5" />
    <tr><td>&nbsp;</td><td><?php if(isset($_POST['submit']) && $nbrErrors>0){ echo '<div class="submitError"><br />'.$errorsText.'<br /></div>'; }?></td></tr>
    <?php
    $tabAttributesValues_1['value'][5]="valider";
    ?>
    <tr><td><input id="element_id1-0" name="submit" type="submit" class="formallin_submit"  value="<?php echo $tabAttributesValues_1['value'][$lang_id];?>"  /> -
    <?php
    $tabAttributesValues_2['value'][5]="effacer";
    ?>
    <input id="element_id2-0" name="reset" type="reset" class="formallin_reset"  value="<?php echo $tabAttributesValues_2['value'][$lang_id];?>"  /></td></tr>
    </table>
    </fieldset>
    </form>
    <?php
    if(isset($_POST['submit']) && $nbrErrors==0){
    $lang = $_GET['lang'];
    // si le message a bien été transmis
    $tabLangSuccess['fr'] = "Les informations que vous avez saisies ont bien été transmises. Nous vous en remercions."; // France
     
    // si le message n'a pu être transmis
    $tabLangFailure['fr'] = "Les informations que vous avez saisies n'ont pu être transmises, veuillez réessayer ultérieurement."; // France
    $messageText = $tabLangSuccess[$lang];
     
    $successMessage=<<<msn
    <script type="text/javascript">
    var SUCCESS_MESSAGE="$messageText";
    </script>
    msn;
    echo $successMessage;
    ?>
    <script type="text/javascript">
    $(document).ready(function(){
     
        var bgColor = $('fieldset').css('backgroundColor');
     
        // effet lumineux et confirmation de soumission du formulaire
        $('fieldset').animate({backgroundColor:"#9ee19a", opacity:0},500)
        .animate({backgroundColor:bgColor,opacity:1},500 )
        .animate({opacity:0},500 )
        .queue(function(){
            $('fieldset').html('<div id="success">'+SUCCESS_MESSAGE+'</div>').css({opacity:1});
            $('#success').hide().fadeIn('slow');
        })
    });
    </script>
    <?php
    };
    ?>
    <?php } ?>
    </body>
    </html>
    </body>
    </html>
    Merci pour le coup de main

  4. #4
    Expert confirmé
    Avatar de laurentSc
    Homme Profil pro
    Webmaster débutant perpétuel !
    Inscrit en
    Octobre 2006
    Messages
    10 470
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmaster débutant perpétuel !
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2006
    Messages : 10 470
    Points : 5 828
    Points
    5 828
    Billets dans le blog
    1
    Par défaut
    Je ne suis pas motivé pour regarder le code de 868 lignes par contre y a des soucis ds la recette pour le code postal :

    - la condition
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    if(isset(!empty($_POST['code_postal']))
    ne colle pas vu que empty retourne un booléen et que isset attend une variable ;
    - foreach($cp as $code => $var){ ne colle pas non plus vu que foreach travaille sur un tableau et que $cp n'est qu'une variable scalaire...

  5. #5
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2013
    Messages
    55
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 55
    Points : 27
    Points
    27
    Par défaut
    Bonsoir

    La variable $tabLabelText[0] est à la ligne 799
    J'aimerais bien faire une bonne soupe.
    En suivant ton idée, j'obtient plus ou moins ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    <?php
     
    $tab_cp=array('93', '95', '60', '62' , '80' , '59' , '02' , '27' , '28' , '76' ,  '14' , '50'); // Tableaux des codes postaux
    $select_email=0;
     
    if(isset($_POST['$tabLabelText[0]']))
    {
        $cp=$_POST['$tabLabelText[0]'];
        $int_cp = intval(substr($cp,0,2)); //Troncature du code postal pour ne garder que les 2 premiers caracteres et transforme en entier
     
        	if($int_cp == $var){
        	    $select_email=1; // Si code postal est dans la liste on choisi cet email
        	}
       }
     
    if($select_email == '1'){
    	$email="adresseA@gmail.com";// informations identiques quelque soit le jour
        $formName="Devis campagne N°1"; 
        $emailSubject="Informations transmises par le formulaire"; 
    }else{
    	if( date("d") % 2 == 0 ) // nous sommes un jour pair
        $email="iadresseA@gmail.com";
    else
      $email="adresseB@gmail.com";// informations identiques quelque soit le jour
      $formName="Devis campagne N°1"; 
      $emailSubject="Informations transmises par le formulaire";
    }
     
    ?>
    Même si je ne suis pas bon cuisinier! Qu'en pense tu Laurent?

  6. #6
    Expert confirmé
    Avatar de laurentSc
    Homme Profil pro
    Webmaster débutant perpétuel !
    Inscrit en
    Octobre 2006
    Messages
    10 470
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmaster débutant perpétuel !
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2006
    Messages : 10 470
    Points : 5 828
    Points
    5 828
    Billets dans le blog
    1
    Par défaut
    Ce que j'en pense, c'est qu'à la place de if($int_cp == $var) (où $var est inconnue), je mettrais if (in_array($int_cp,$tab_cp)).

    Et de plus, les affectations de $formName et $emailSubject étant identiques ds les 2 conditions, je les sortirais du if.

  7. #7
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2013
    Messages
    55
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 55
    Points : 27
    Points
    27
    Par défaut
    Merci Laurent
    Donc comme ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    <?php
     
    $tab_cp=array('93', '95', '60', '62' , '80' , '59' , '02' , '27' , '28' , '76' ,  '14' , '50'); // Tableaux des codes postaux
    $select_email=0;
     
    if(isset($_POST['$tabLabelText[0]']))
    {
      $cp=$_POST['$tabLabelText[0]'];
      $int_cp = intval(substr($cp,0,2)); //Troncature du code postal pour ne garder que les 2 premiers caracteres et transforme en entier
     
    	if (in_array($int_cp,$tab_cp)){
      $select_email=1; // Si code postal est dans la liste on choisi cet email
        	}
       }
     
    if($select_email == '1'){
      $email="adresseA@gmail.com";// code postal dans la liste
     
    }else{
    	if( date("d") % 2 == 0 ) // nous sommes un jour pair
      $email="adresseA@gmail.com";
    else
      $email="adresseB@gmail.com";// nous sommes un jour impair
      $formName="Devis campagne N°1"; 
      $emailSubject="Informations transmises par le formulaire";
    }
     
    ?>
    J'ai fait un test, pour voir!
    Avec un departement 95 qui figure dans la liste et autre 78 qui lui n'y figure pas, les 2 arrivent dans adresseB@gmail.com
    C'est encore un peu fade, j'ai fait une erreur?

  8. #8
    Expert confirmé
    Avatar de laurentSc
    Homme Profil pro
    Webmaster débutant perpétuel !
    Inscrit en
    Octobre 2006
    Messages
    10 470
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmaster débutant perpétuel !
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2006
    Messages : 10 470
    Points : 5 828
    Points
    5 828
    Billets dans le blog
    1
    Par défaut
    presque :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
      <?php
     
    $tab_cp=array('93', '95', '60', '62' , '80' , '59' , '02' , '27' , '28' , '76' ,  '14' , '50'); // Tableaux des codes postaux
    $select_email=0;
     
    if(isset($_POST['$tabLabelText[0]']))
    {
      $cp=$_POST['$tabLabelText[0]'];
      $int_cp = intval(substr($cp,0,2)); //Troncature du code postal pour ne garder que les 2 premiers caracteres et transforme en entier
     
    	if (in_array($int_cp,$tab_cp)){
      $select_email=1; // Si code postal est dans la liste on choisi cet email
        	}
       }
     
    if($select_email == '1'){
      $email="adresseA@gmail.com";// code postal dans la liste
     
    }else{
    	if( date("d") % 2 == 0 ) // nous sommes un jour pair
      $email="adresseA@gmail.com";
    else
      $email="adresseB@gmail.com";// nous sommes un jour impair
    }
      $formName="Devis campagne N°1"; 
      $emailSubject="Informations transmises par le formulaire";
     
     
    ?>
    Les 2 affectations, tu les avais laissées ds le else.

  9. #9
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2013
    Messages
    55
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 55
    Points : 27
    Points
    27
    Par défaut
    Ok Laurent
    J'ai refait un test
    Le code postal 95 est tombé dans adresseB@gmail.com
    Le code postal 78 est bien arrivé dans adresseB@gmail.com, jour impair
    Tu vois autre chose?

  10. #10
    Expert confirmé
    Avatar de laurentSc
    Homme Profil pro
    Webmaster débutant perpétuel !
    Inscrit en
    Octobre 2006
    Messages
    10 470
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmaster débutant perpétuel !
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2006
    Messages : 10 470
    Points : 5 828
    Points
    5 828
    Billets dans le blog
    1
    Par défaut
    Oui !! il manque les guillemets ligne 13.

  11. #11
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2013
    Messages
    55
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 55
    Points : 27
    Points
    27
    Par défaut
    Ok, j'ai donc corriger comme ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    <?php
     
    $tab_cp=array('93', '95', '60', '62' , '80' , '59' , '02' , '27' , '28' , '76' ,  '14' , '50'); // Tableaux des codes postaux
    $select_email='0';
     
    if(isset($_POST['$tabLabelText[0]']))
    {
      $cp=$_POST['$tabLabelText[0]'];
      $int_cp = intval(substr($cp,0,2)); //Troncature du code postal pour ne garder que les 2 premiers caracteres et transforme en entier
     
    	if (in_array($int_cp,$tab_cp)){
      $select_email='1'; // Si code postal est dans la liste on choisi cet email
        	}
       }
     
    if($select_email == '1'){
      $email="adresseA@gmail.com";// code postal dans la liste
     
    }else{
    	if( date("d") % 2 == 0 ) // nous sommes un jour pair
      $email="adresseA@gmail.com";
    else
      $email="adresseB@gmail.com";// nous sommes un jour impair
    }
      $formName="Devis campagne N°1"; 
      $emailSubject="Informations transmises par le formulaire";
     
     
    ?>
    Et donc la même chose ligne 5
    $select_email=0; pour $select_email='0';
    Mais pareil 95 et 78 tombent dans adresseB@gmail.com
    Peut-être encore autre chose?

  12. #12
    Membre averti

    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2011
    Messages
    205
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2011
    Messages : 205
    Points : 409
    Points
    409
    Billets dans le blog
    1
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $_POST['$tabLabelText[0]']
    $tabLabelText[0] est ici considéré comme une chaîne de caractère et ne sera donc pas interprété. Si tu souhaites récupérer le contenu du premier élément de ton tableau $tabLabelText, tu dois l'indiquer ainsi (sans les guillemets simples) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $_POST[$tabLabelText[0]]
    J'espère que c'est un problème de mise en forme lié au forum aussi mais je te conseille de revoir ton indentation, pour plus de lisibilité

  13. #13
    Expert confirmé
    Avatar de laurentSc
    Homme Profil pro
    Webmaster débutant perpétuel !
    Inscrit en
    Octobre 2006
    Messages
    10 470
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 60
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmaster débutant perpétuel !
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2006
    Messages : 10 470
    Points : 5 828
    Points
    5 828
    Billets dans le blog
    1
    Par défaut
    Je ne suis pas convaincu ; pour y voir plus clair, je mettrais un var_dump($tabLabelText) dans mon code...

  14. #14
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Points : 91 220
    Points
    91 220
    Billets dans le blog
    20
    Par défaut
    Je ne suis pas convaincu
    De quoi, de la réponse de k'amm ?

    A moins qu'il n'y ai un champ nommé $tabLabelText[0] dans le formulaire, sa réponse est d'une logique implacable...

  15. #15
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2013
    Messages
    55
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 55
    Points : 27
    Points
    27
    Par défaut
    Bonjour
    J'ai donc tester l'idée de k'amm
    Mais pareil 95 et 78 tombent dans adresseB@gmail.com
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    <?php if( isset($_POST['submit']) ){ // le formulaire a été posté
    $tab_cp=array('93', '95', '60', '62' , '80' , '59' , '02' , '27' , '28' , '76' ,  '14' , '50'); // Tableaux des codes postaux
    $select_email='0';
     
    if(isset($_POST[$tabLabelText[0]]))
    {
      $cp=$_POST[$tabLabelText[0]];
      $int_cp = intval(substr($cp,0,2)); //Troncature du code postal pour ne garder que les 2 premiers caracteres et transforme en entier
     
    if(in_array($int_cp,$tab_cp)){
      $select_email='1'; // Si code postal est dans la liste on choisi cet email
        	}
       }
    if($select_email == '1'){
      $email="adresseA@gmail.com";// code postal dans la liste
     
    }else{
    	if( date("d") % 2 == 0 ) // nous sommes un jour pair
      $email="adresseA@gmail.com";
    else
      $email="adresseB@gmail.com";// nous sommes un jour impair
    }
      $formName="Devis campagne N°1"; 
      $emailSubject="Informations transmises par le formulaire";
    ?>
     
    <?php
    Je remet le fichier en entier ci dessous
    Le champ code postal $tabLabelText[0] est bien à la ligne 799
    en réalité j'ai plusieurs champs dans mon formulaire (c'est pour faire + simple)
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
    827
    828
    829
    830
    831
    832
    833
    834
    835
    836
    837
    838
    839
    840
    841
    842
    843
    844
    845
    846
    847
    848
    849
    850
    851
    852
    853
    854
    855
    856
    857
    858
    859
    860
    861
    862
    863
    864
    865
    866
    867
    868
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
    <title>Untitled Document</title>
    </head>
     
    <body>
    <?php session_start(); header("Content-Type: text/html; charset=UTF-8"); ?>
    <?php
    /*
     * Formulaire généré par formallin v2.3.0
     * Auteur : Grégory Toucas
     * http://www.atomestudio.com / contact@atomestudio.com
     * Soutenu par l'agence web IDEEMATIC : http://www.ideematic.com
     *
     * Programme sous licence GPL:
     * http://www.gnu.org/licenses/gpl.html
     *
    */
    echo '
    <!--
    Formulaire généré par formallin v2.3.0
    Auteur : Grégory Toucas
    http://www.atomestudio.com / contact@atomestudio.com
    Soutenu par l agence web IDEEMATIC : http://www.ideematic.com
     
    Programme sous licence GPL:
    http://www.gnu.org/licenses/gpl.html
    -->
    ';
    ?>
    <?php
    $tabFieldsetLegends[5]="Titre";
    ?>
    <?php
    // Ensemble de fonctions
    function fa_phpToJs($var) {
        if (is_array($var)) {
            $res = "[";
            $array = array();
            foreach ($var as $a_var) {
                $array[] = fa_phpToJs($a_var);
            }
            return "[" . join(",", $array) . "]";
        }
        elseif (is_bool($var)) {
            return $var ? "true" : "false";
        }
        elseif (is_int($var) || is_integer($var) || is_double($var) || is_float($var)) {
            return $var;
        }
        elseif (is_string($var)) {
            return "\"" . addslashes(stripslashes($var)) . "\"";
        }
        // autres cas: objets, on ne les gère pas
        return FALSE;
    }
     
    function fa_str_post($string){
        if (isset($_POST[$string])) { $return_string = trim($_POST[$string]); } else { $return_string = ""; }
        return $return_string;
    }
    ?>
            <script type="text/javascript">
            var tabErrorFields=new Array();
            var tabErrorFormats=new Array();
            var tabFieldsRequired=new Array();
            var tabFormatsRequired=new Array();
            </script><?php $list_langIds="5"; $tab_langIds=explode(",",$list_langIds); ?>
    <?php
    $tabShortNames[0]="zh";
    $tabShortNames[1]="ca";
    $tabShortNames[2]="da";
    $tabShortNames[3]="de";
    $tabShortNames[4]="fr";
    $tabShortNames[5]="it";
    $tabShortNames[6]="pt";
    $tabShortNames[7]="ru";
    $tabShortNames[8]="es";
    $tabShortNames[9]="en";
    $tabShortNames[10]="ro";
    $tabShortNames[11]="pl";
    $tabShortNames[12]="nl";
    ?>
    <?php if(is_array($tabShortNames)){ $lang_id=array_search($_GET['lang'],$tabShortNames)+1; }else{ $lang_id=""; }?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $_GET['lang'];?>" xml:lang="<?php echo $_GET['lang'];?>">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title></title>
    <script type="text/javascript">var langId="<?php echo $lang_id;?>"; var issetCaptcha=false;</script>
    <style type="text/css">
     
            body {
                margin: 0px; padding: 0px; width:100%;
                font-family: "Trebuchet MS",arial,verdana, serif;
                font-weight: normal; font-size: 10px; color: #48566e;  text-align: left; /* line-height: 1.3em; */
                overflow-x: hidden;
                /* overflow-y: hidden; */
            }
     
            span.span_chbx_radio { float:left; width:200px; }
     
            input[type=submit] { opacity: 0.8; padding:5px; -moz-border-radius:5px; -webkit-border-radius:5px; -khtml-border-radius:5px; border:1px solid #E2E2E7; background-color:#8BA9DC; color:#ffffff; cursor: pointer;}
            input[type=reset] { opacity: 0.8; padding:5px; -moz-border-radius:5px; -webkit-border-radius:5px; -khtml-border-radius:5px; border:1px solid #E2E2E7; background-color:#f5f5f5; color:#333333; cursor: pointer;}
     
            input[type=submit]:hover, input[type=reset]:hover { opacity:0.5; }
     
            a { color:#48566e; }
     
            input[type=text], input[type=password] {
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;
                border:1px solid #8BA9DC;
                background-color:#ffffff;
                color:#48566e;
            }
     
            textarea {
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;
                border:1px solid #8BA9DC;
                background-color:#ffffff;
                color:#48566e; 
            }
     
            fieldset {
                border:1px solid #8BA9DC;
                background-color:#ffffff;
                margin: 5px;
                min-height: 100px;
                -moz-border-radius:5px;
                -webkit-border-radius:5px;
                -khtml-border-radius:5px;
            }
     
            legend {
                border:1px solid #ffffff;
                background-color: #ffffff;
                padding:4px;
                color:#8BA9DC;
                -moz-border-radius:4px;
                -webkit-border-radius:4px;
                -khtml-border-radius:4px;
                font-size:1.2em;
            }
     
            .errorMessage {
                font-size: 0.8em;
                color:#cc0000;  
            }
     
            .errorField, .errorFormat {
                background-color: #ffe6e6;
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;  
            }
     
            .submitError {
                padding:5px;
                color:#cc0000;
                border: 1px solid #cc0000;
                background-color: #ffe6e6;
                -moz-border-radius:3px;
                -webkit-border-radius:3px;
                -khtml-border-radius:3px;
            }
     
            label, .span_chbx_radio {
                color:#48566e;
                font-size: 0.8em;
            }
     
            .obligatoryField {
                color:#cc0000;
                font-size: 1.2em;
            }
     
            #success {
                padding: 20px;
                font-size: 16px;
            }      
            </style>
    <link rel="stylesheet" type="text/css" href="http://jquery-ui.googlecode.com/svn/tags/latest/themes/base/jquery.ui.all.css" />
    <script src="../js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="../js/jquery-ui.min.js" type="text/javascript"></script>
    <script src="../js/jquery.ui.datepicker.min.js"></script>
    <script type="text/javascript">
    $(function(){ $(".datepicker").datepicker({changeMonth: true,changeYear: true}); });
    </script>
    <script type="text/javascript">function validForm(){
     
        /*
         * Initialisation des variables
         */
     
        var nbrErrors=0;
     
     
        /*
         * Fonctions de vérification des formatages
         */
     
        function verifNumber(myString){ // idTag 3 
            if(isNaN(myString)){ return false; }else { return true; }  
        }
     
     
        function verifEmail(myString){ // idTag 4
     
            var reg= /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
     
            if(reg.test(myString)==true){
                return true; // adresse valide
            }
            else{
                return false; // adresse non valide
            }
        }
     
     
        function verfifUrl(myString){ // idTag 5
     
            var reg= /(http):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
     
            if(reg.test(myString)==true){
                return true; // adresse valide
            }
            else{
                return false; // adresse non valide
            }
     
        }  
     
        function verifCaptcha(myString){ // idTag 15
            myString = jQuery.trim(myString);
     
            if(myString==''){
                return false;
            }else{
                return true;
            }
        }
     
        /*
         * Gestion des FieldsetErrors
         */
     
        function verifField(){
     
            $.each(tabFieldsRequired, function(index,n){
                var i=0;
                var type=$('#element_id'+n+'-'+i).attr("type");
                var str=$('#element_id'+n+'-'+i).val();
     
                if(type=="checkbox" || type=="radio"){
     
                    var checkStr=false;
                    while(typeof $('#element_id'+n+'-'+i).attr('checked')!=="undefined"){
                        if($('#element_id'+n+'-'+i).attr('checked')==true){checkStr=true;}
                        i++;
                    }
                    if(checkStr==false){
                        $('#errorField_'+n).html(tabErrorFields[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                        nbrErrors++;
                    }else{
                        $('#errorField_'+n).html('').css({"padding":"0px"});
                    }
                }else{
     
                    str = jQuery.trim(str);
     
                    if(str==''){
                        $('#errorField_'+n).html(tabErrorFields[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                        nbrErrors++;
                    }
                    else{
                        if(str!=''){                   
                            $('#errorField_'+n).html('').css({"padding":"0px"});
                        }
                    }
                }
     
                // Gestion du captcha
                var ElemClass=$('#element_id'+n+'-'+i).attr("class");
                if(ElemClass=='formallin_captcha' && !verifCaptcha(str)){
                    $('td#tdCaptcha input').css({"background-color":"FFE6E6"});
                    nbrErrors++;
                }else{
                    $('td#tdCaptcha input').css({"background-color":"fff"});
                }
            });
        }
     
        /*
         * Gestion des FormatErrors
         */
     
        function verifFormat(){
     
            $.each(tabFormatsRequired, function(index,n){
                var i=0;
     
                var ElemClass=$('#element_id'+n+'-'+i).attr("class");
                var ElemValue=$('#element_id'+n+'-'+i).val();
                ElemValue = jQuery.trim(ElemValue);
     
                switch(ElemClass){
     
                case 'formallin_numeric' : if(!verifNumber(ElemValue) && ElemValue!=''){
                    $('#errorFormat_'+n).html(tabErrorFormats[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                    nbrErrors++;
                }else{
                    $('#errorFormat_'+n).html('').css({"padding":"0px"});
                }
                break;
     
                case 'formallin_email' : if(!verifEmail(ElemValue) && ElemValue!=''){
                    $('#errorFormat_'+n).html(tabErrorFormats[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                    nbrErrors++;
                }else{
                    $('#errorFormat_'+n).html('').css({"padding":"0px"});
                }
                break;
     
                case 'formallin_url' : if(!verfifUrl(ElemValue) && ElemValue!=''){
                    $('#errorFormat_'+n).html(tabErrorFormats[n][langId]).hide().fadeIn(2000).css({"padding":"2px 2px 2px 8px"});
                    nbrErrors++;
                }else{
                    $('#errorFormat_'+n).html('').css({"padding":"0px"});
                }
                break;
     
    //          case 'datepicker' : ;
    //          break;
     
                }
     
     
            });
        }
     
        /*
         * Execution des tests
         */
     
        verifField();
        verifFormat();
     
        /*
         * Evaluation finale
         */
     
        if(nbrErrors==0){
            return true;
        }else{
            return false;
        }
    }</script>
     
            <?php
            switch($lang_id){
     
                case 1 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-zh-CN.js"></script>';
                        break;
     
                case 2 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-ca.js"></script>';
                        break;
     
                case 3 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-da.js"></script>';
                        break;
     
                case 4 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-de.js"></script>';
                        break;
     
                case 5 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-fr.js"></script>';
                        break;
     
                case 6 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-it.js"></script>';
                        break;
     
                case 7 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-pt-BR.js"></script>';
                        break;
     
                case 8 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-ru.js"></script>';
                        break;
     
                case 9 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-es.js"></script>';
                        break;
     
                case 10 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-en-GB.js"></script>';
                        break;
     
                case 11 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-ro.js"></script>';
                        break;
     
                case 12 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-pl.js"></script>';
                        break;
     
                case 13 : echo '<script src="../js/datepicker_i8n/jquery.ui.datepicker-nl.js"></script>';
                        break;
            }
            ?>
     
     
     
     
     
    </head>
    <body>
    <?php define("_TAB_FORMALLEX","formallin_formallex"); ?>
    <?php $sessionFormallinEditor = "W74sbtAurtDHqKSHwsTQL71KinteXLdSi7kjICvY"; ?>
    <?php if( isset($_POST['submit']) ){ // le formulaire a été posté
      if( date("d") % 2 == 0 ) // nous sommes un jour pair
        $email="adresseA@gmail.com";
      else
        $email="adresseB@gmail.com";
      // informations identiques quelque soit le jour
      $formName="Devis campagne N°1"; 
      $emailSubject="Informations transmises par le formulaire";
      ?>
     
    <?php
    //-------------------------------------------------------------------------------------------------------
    /* version  1.3 | author : Leo West | lwest@free.fr
     */
    class Mail{
        var $sendto = array();
        var $acc = array();
        var $abcc = array();
        var $aattach = array();
        var $xheaders = array();
        var $priorities = array( '1 (Highest)', '2 (High)', '3 (Normal)', '4 (Low)', '5 (Lowest)' );
        var $charset = "utf-8"; /* us-ascii */
        var $ctencoding = "7bit";
        var $receipt = 0;
     
        function Mail(){
            $this->autoCheck( true );
            $this->boundary= "--" . md5( uniqid("myboundary") );
        }
     
        function autoCheck( $bool ){
            if( $bool )
            $this->checkAddress = true;
            else
            $this->checkAddress = false;
        }
     
        function Subject( $subject ){
            $this->xheaders['Subject'] = strtr( $subject, "\r\n" , "  " );
        }
     
        function From( $from ){
            if( ! is_string($from) ) {
                echo "Class Mail: error, From is not a string";
                exit;
            }
            $this->xheaders['From'] = $from;
        }
     
        function ReplyTo( $address ){
            if( ! is_string($address) )
            return false;
            $this->xheaders["Reply-To"] = $address;
        }
     
        function Receipt(){
            $this->receipt = 1;
        }
     
        function To( $to ){
            if( is_array( $to ) )
            $this->sendto= $to;
            else
            $this->sendto[] = $to;
            if( $this->checkAddress == true )
            $this->CheckAdresses( $this->sendto );
        }
     
        function Cc( $cc ){
            if( is_array($cc) )
            $this->acc= $cc;
            else
            $this->acc[]= $cc;
            if( $this->checkAddress == true )
            $this->CheckAdresses( $this->acc );
        }
     
        function Bcc( $bcc ){
            if( is_array($bcc) ) {
                $this->abcc = $bcc;
            } else {
                $this->abcc[]= $bcc;
            }
            if( $this->checkAddress == true )
            $this->CheckAdresses( $this->abcc );
        }
     
        function Body( $body, $charset="" ){
            $this->body = $body;
            if( $charset != "" ) {
                $this->charset = strtolower($charset);
                if( $this->charset != "utf-8" ) /* us-ascii */
                $this->ctencoding = "8bit";
            }
        }
     
        function Organization( $org ){
            if( trim( $org != "" )  )
            $this->xheaders['Organization'] = $org;
        }
     
        function Priority( $priority ){
            if( ! intval( $priority ) )
            return false;
            if( ! isset( $this->priorities[$priority-1]) )
            return false;
            $this->xheaders["X-Priority"] = $this->priorities[$priority-1];
            return true;
        }
     
        function Attach( $filename, $filetype = "", $disposition = "inline" ){
            if( $filetype == "" )
            $filetype = "application/x-unknown-content-type";
            $this->aattach[] = $filename;
            $this->actype[] = $filetype;
            $this->adispo[] = $disposition;
        }
     
        function BuildMail(){
            $this->headers = "";
            if( count($this->acc) > 0 )
            $this->xheaders['CC'] = implode( ", ", $this->acc );
            if( count($this->abcc) > 0 )
            $this->xheaders['BCC'] = implode( ", ", $this->abcc );
            if( $this->receipt ) {
                if( isset($this->xheaders["Reply-To"] ) )
                $this->xheaders["Disposition-Notification-To"] = $this->xheaders["Reply-To"];
                else
                $this->xheaders["Disposition-Notification-To"] = $this->xheaders['From'];
            }
            if( $this->charset != "" ) {
                $this->xheaders["Mime-Version"] = "1.0";
                $this->xheaders["Content-Type"] = "text/plain; charset=$this->charset";
                $this->xheaders["Content-Transfer-Encoding"] = $this->ctencoding;
            }
            $this->xheaders["X-Mailer"] = "Php/libMailv1.3";
            if( count( $this->aattach ) > 0 ) {
                $this->_build_attachement();
            } else {
                $this->fullBody = $this->body;
            }
            reset($this->xheaders);
            while( list( $hdr,$value ) = each( $this->xheaders )  ) {
                if( $hdr != "Subject" )
                $this->headers .= "$hdr: $value\n";
            }
        }
     
        function Send(){
            $this->BuildMail();
            $this->strTo = implode( ", ", $this->sendto );
            $res = @mail( $this->strTo, $this->xheaders['Subject'], $this->fullBody, $this->headers );
        }
     
        function Get(){
            $this->BuildMail();
            $mail = "To: " . $this->strTo . "\n";
            $mail .= $this->headers . "\n";
            $mail .= $this->fullBody;
            return $mail;
        }
     
        function ValidEmail($address){
            if( preg_match( "#.*<(.+)>#", $address, $regs ) ) {
                $address = $regs[1];
            }
            if(preg_match( "#^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$#",$address) )
            return true;
            else
            return false;
        }
     
        function CheckAdresses( $aad ){
            for($i=0;$i< count( $aad); $i++ ) {
                if( ! $this->ValidEmail( $aad[$i]) ) {
                    echo "Class Mail, method Mail : invalid address $aad[$i]";
                    exit;
                }
            }
        }
     
        function _build_attachement(){
            $this->xheaders["Content-Type"] = "multipart/mixed;\n boundary=\"$this->boundary\"";
            $this->fullBody = "This is a multi-part message in MIME format.\n--$this->boundary\n";
            $this->fullBody .= "Content-Type: text/plain; charset=$this->charset\nContent-Transfer-Encoding: $this->ctencoding\n\n" . $this->body ."\n";
            $sep= chr(13) . chr(10);
            $ata= array();
            $k=0;
            for( $i=0; $i < count( $this->aattach); $i++ ) {
                $filename = $this->aattach[$i];
                $basename = basename($filename);
                $ctype = $this->actype[$i];  // content-type
                $disposition = $this->adispo[$i];
                if( ! file_exists( $filename) ) {
                    echo "Class Mail, method attach : file $filename can't be found"; exit;
                }
                $subhdr= "--$this->boundary\nContent-type: $ctype;\n name=\"$basename\"\nContent-Transfer-Encoding: base64\nContent-Disposition: $disposition;\n  filename=\"$basename\"\n";
                $ata[$k++] = $subhdr;
                $linesz= filesize( $filename)+1;
                $fp= fopen( $filename, 'r' );
                $ata[$k++] = chunk_split(base64_encode(fread( $fp, $linesz)));
                fclose($fp);
            }
            $this->fullBody .= implode($sep, $ata);
        }
    }
    //-------------------------------------------------------------------------------------------------------
    ?><?php
    $tabGroupeElementsLabel=unserialize(base64_decode($_POST['tabGroupeElementsLabel']));
    $tabLabelText=unserialize(base64_decode($_POST['tabLabelText']));
    $tabErrorFields=unserialize(base64_decode($_POST['tabErrorFields']));
    $tabErrorFormats=unserialize(base64_decode($_POST['tabErrorFormats']));
    $tabShortNames=unserialize(base64_decode($_POST['tabShortNames']));
    $lang_id=array_search($_GET['lang'],$tabShortNames)+1;
    $sys_lang_id=$_POST['sli'];
     
    $lines='IP : '.$_SERVER['SERVER_ADDR'].'<br />'; // collecte de l'ip du visiteur
    $nbrErrors=0;
    $errorsText='';
     
    foreach($tabGroupeElementsLabel as $key=>$tab){
        $tagId=$tab[0];
        $textLabel=$tabLabelText[$key][$lang_id];
        $fieldRequired=$tab[2];
        if($fieldRequired=="yes"){
            switch($tagId){
                case 1 : if(isset($_POST['element_text'][$key])){$val=trim($_POST['element_text'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 2 : if(isset($_POST['element_password'][$key])){$val=trim($_POST['element_password'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 3 : if(isset($_POST['element_numeric'][$key])){$val=trim($_POST['element_numeric'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 4 : if(isset($_POST['element_email'][$key])){$val=trim($_POST['element_email'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 5 : if(isset($_POST['element_url'][$key])){$val=trim($_POST['element_url'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 6 : if(isset($_POST['element_textarea'][$key])){$val=trim($_POST['element_textarea'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 7 : if(isset($_POST['element_checkbox'][$key])){$val=trim($_POST['element_checkbox'][$key][0]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 8 : if(isset($_POST['element_radio'][$key])){$val=trim($_POST['element_radio'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 9 : if(isset($_POST['element_select'][$key])){$val=trim($_POST['element_select'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 10 : if(isset($_POST['element_datepicker'][$key])){$val=trim($_POST['element_datepicker'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 11 : if(isset($_POST['element_file'][$key])){$val=trim($_POST['element_file'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.="\"$textLabel\" : ".$tabErrorFields[$key][$lang_id]."<br />";} break;
                case 15 : if(isset($_POST['element_captcha'][$key])){$val=trim($_POST['element_captcha'][$key]);} if(empty($val)){ $nbrErrors++; $errorsText.=$tabErrorFields[$key][$lang_id]."<br />";} break;
            }
        }
    }
     
     
    if($nbrErrors==0){
     
        foreach($tabGroupeElementsLabel as $key=>$tab){
     
            foreach($tab as $tagId=>$textLabel){
                $tagId=$tab[0];
                $textLabel=$tabLabelText[$key][$lang_id];
            }
     
            if($tagId==3){
                if (!is_numeric($_POST['element_numeric'][$key]) && !empty($_POST['element_numeric'][$key])){
                    $nbrErrors++;
                    $errorsText.='"'.$textLabel.'" : ';
                    $errorsText.=$tabErrorFormats[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
            elseif($tagId==4){
                if (!preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['element_email'][$key]) && !empty($_POST['element_email'][$key])){
                    $nbrErrors++;
                    $errorsText.='"'.$textLabel.'" : ';
                    $errorsText.=$tabErrorFormats[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
            elseif($tagId==5){
                if(strpos($_POST['element_url'][$key], 'http://') === FALSE && !empty($_POST['element_url'][$key])){
                    $nbrErrors++;
                    $errorsText.='"'.$textLabel.'" : ';
                    $errorsText.=$tabErrorFormats[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
            elseif($tagId==10){
            }
            elseif($tagId==11){
     
                //print_r($tabExtension);
     
            }
            elseif($tagId==15){
                if( isset($_SESSION['security_code']) && ($_SESSION['security_code'] != $_POST['element_captcha'][$key])) {
                    $nbrErrors++;
                    $errorsText.=$tabErrorFields[$key][$lang_id]."<br />";
                    $errorsText.="<br />";
                }
            }
        }
     
     
        if($nbrErrors==0){
     
            /*
             * Récupération des Labels et des champs pour l'email envoyé au contact administratif
             */
     
            foreach($tabGroupeElementsLabel as $key=>$tab){
     
                foreach($tab as $tagId=>$textLabel){
                    $tagId=$tab[0];
                    $textLabel=$tab[1];
                }
     
                if($tagId!=15){$lines.=$textLabel.' : ';}
     
                switch($tagId){
                    case 1 : if(isset($_POST['element_text'][$key])){$lines.=trim($_POST['element_text'][$key]);} break;
                    case 2 : if(isset($_POST['element_password'][$key])){$lines.=trim($_POST['element_password'][$key]);} break;
                    case 3 : if(isset($_POST['element_numeric'][$key])){$lines.=trim($_POST['element_numeric'][$key]);} break;
                    case 4 : if(isset($_POST['element_email'][$key])){$lines.=trim($_POST['element_email'][$key]);} break;
                    case 5 : if(isset($_POST['element_url'][$key])){$lines.=trim($_POST['element_url'][$key]);} break;
                    case 6 : if(isset($_POST['element_textarea'][$key])){$lines.=trim($_POST['element_textarea'][$key]);} break;
                    case 7 : if(isset($_POST['element_checkbox'][$key]) && !empty($_POST['element_checkbox'][$key])){foreach($_POST['element_checkbox'][$key] as $key=>$value){$lines.=trim($value).", ";}} break;
                    case 8 : if(isset($_POST['element_radio'][$key])){$lines.=trim($_POST['element_radio'][$key]);} break;
                    case 9 : if(isset($_POST['element_select'][$key])){$lines.=trim($_POST['element_select'][$key]);} break;
                    case 10 : if(isset($_POST['element_datepicker'][$key])){$lines.=trim($_POST['element_datepicker'][$key]);} break;
                    case 11 : if(isset($_POST['element_file'][$key])){$lines.=trim($_POST['element_file'][$key]);} break;
                }
     
                $lines.="<br /><br />";
            }
     
            /*
             * Envoi de l'email
             */
     
            $lines=str_replace("<br />","\n",$lines);
     
            $em=explode(";",$email);
     
            foreach($em as $e){ // boucle pour transmettre la soumission du formulaire à tous les destinataires concernés
     
                // construction de l'email
                $subject=$emailSubject.' ['.$formName.']';
                $tab=explode("@",$e);
                $ndd=$tab[1];
                $expediteur="no-reply@$ndd";
     
                $m= new Mail;
                $m->From($expediteur);
                $m->To($e);
                $m->Subject($subject);
                $m->Body(stripslashes($lines));
                $m->Priority(1);
     
                // envoie de l'email
                $m->Send();
            }
     
            include_once("../../connectors/formallin_connector_bddAcces.php"); /* FORMALLIN */
     
            // connexion
            global $db;
            include("../../db.php");
            $db=new DB;
            $db->_connectar();
     
            include_once('../classes/FA_Sql.class.php');
            include_once('../classes/FA_Formallex.class.php');
     
            function fa_inDB($string){
                return mysql_real_escape_string(stripslashes($string));
            }
     
            $formallex = new FA_Formallex();
            $formallex->setSessionFormallinEditor($sessionFormallinEditor);
            $formallex->setContent(stripslashes($lines));
            $formallex->createFormallex();
     
            $db->_desconnectar();       
        }
    }
    ?><?php } ?><?php if(in_array($lang_id,$tab_langIds)){ ?>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>?lang=<?php echo $_GET['lang'];?>" onSubmit="return validForm();">
    <fieldset>
    <legend><?php echo $tabFieldsetLegends[$lang_id];?></legend>
    <table>
    <?php
    $tabLabelText[0][5]="Code postal";
    ?>
    <script type="text/javascript">
    tabErrorFormats[0] = new Array();
    tabErrorFormats[0][5]="le format n'est pas respecté";
    tabFormatsRequired.push(0);
    </script>
    <tr>
    <td><label for="element_id0-0"><?php echo $tabLabelText[0][$lang_id];?></label></td>
    <td><input type="text" size="20" maxlength="45" class="formallin_numeric" name="element_numeric[0]" id="element_id0-0"/></td>
    </tr>
    <tr><td></td><td><div class="errorMessage" id="error_0"><div class="errorField" id="errorField_0"></div><div class="errorFormat" id="errorFormat_0"></div></div></td></tr><tr><td></td><td></td></tr>
    <input type="hidden" name="tabGroupeElementsLabel" value="YToxOntpOjA7YTozOntpOjA7czoxOiIzIjtpOjE7czoxMToiQ29kZSBwb3N0YWwiO2k6MjtzOjI6Im5vIjt9fQ==" />
    <input type="hidden" name="tabErrorFields" value="czowOiIiOw==" />
    <input type="hidden" name="tabErrorFormats" value="YToxOntpOjA7YToxOntpOjU7czoyOToibGUgZm9ybWF0IG4nZXN0IHBhcyByZXNwZWN0w6kiO319" />
    <input type="hidden" name="tabShortNames" value="<?php echo base64_encode(serialize($tabShortNames));?>" />
    <input type="hidden" name="tabLabelText" value="<?php echo base64_encode(serialize($tabLabelText));?>" />
    <input type="hidden" name="sli" value="5" />
    <tr><td>&nbsp;</td><td><?php if(isset($_POST['submit']) && $nbrErrors>0){ echo '<div class="submitError"><br />'.$errorsText.'<br /></div>'; }?></td></tr>
    <?php
    $tabAttributesValues_1['value'][5]="valider";
    ?>
    <tr><td><input id="element_id1-0" name="submit" type="submit" class="formallin_submit"  value="<?php echo $tabAttributesValues_1['value'][$lang_id];?>"  /> -
    <?php
    $tabAttributesValues_2['value'][5]="effacer";
    ?>
    <input id="element_id2-0" name="reset" type="reset" class="formallin_reset"  value="<?php echo $tabAttributesValues_2['value'][$lang_id];?>"  /></td></tr>
    </table>
    </fieldset>
    </form>
    <?php
    if(isset($_POST['submit']) && $nbrErrors==0){
    $lang = $_GET['lang'];
    // si le message a bien été transmis
    $tabLangSuccess['fr'] = "Les informations que vous avez saisies ont bien été transmises. Nous vous en remercions."; // France
     
    // si le message n'a pu être transmis
    $tabLangFailure['fr'] = "Les informations que vous avez saisies n'ont pu être transmises, veuillez réessayer ultérieurement."; // France
    $messageText = $tabLangSuccess[$lang];
     
    $successMessage=<<<msn
    <script type="text/javascript">
    var SUCCESS_MESSAGE="$messageText";
    </script>
    msn;
    echo $successMessage;
    ?>
    <script type="text/javascript">
    $(document).ready(function(){
     
        var bgColor = $('fieldset').css('backgroundColor');
     
        // effet lumineux et confirmation de soumission du formulaire
        $('fieldset').animate({backgroundColor:"#9ee19a", opacity:0},500)
        .animate({backgroundColor:bgColor,opacity:1},500 )
        .animate({opacity:0},500 )
        .queue(function(){
            $('fieldset').html('<div id="success">'+SUCCESS_MESSAGE+'</div>').css({opacity:1});
            $('#success').hide().fadeIn('slow');
        })
    });
    </script>
    <?php
    };
    ?>
    <?php } ?>
    </body>
    </html>
    </body>
    </html>
    Si vous avez des questions qui viennent dites moi! peut-être je peux répondre, mais je suis novice donc...

    Bonjour Laurent
    pour
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    var_dump($tabLabelText)
    heu...c'est un peu comme ca:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
     
    <?php if( isset($_POST['submit']) ){ // le formulaire a été posté
    $tab_cp=array('93', '95', '60', '62' , '80' , '59' , '02' , '27' , '28' , '76' ,  '14' , '50'); // Tableaux des codes postaux
    $select_email='0';
     
    if(isset(var_dump($tabLabelText)))
    {
      $cp=var_dump($tabLabelText);
      $int_cp = intval(substr($cp,0,2)); //Troncature du code postal pour ne garder que les 2 premiers caracteres et transforme en entier
     
    	if (in_array($int_cp,$tab_cp)){
      $select_email='1'; // Si code postal est dans la liste on choisi cet email
        	}
       }
     
    if($select_email == '1'){
      $email="adresseA@gmail.com";// code postal dans la liste
     
    }else{
    	if( date("d") % 2 == 0 ) // nous sommes un jour pair
      $email="adresseA@gmail.com";
    else
      $email="adresseB@gmail.com";// nous sommes un jour impair
    }
      $formName="Devis campagne N°1"; 
      $emailSubject="Informations transmises par le formulaire";
     
     
    ?>
     
    <?php
    J'ai testé mais page blanche.
    Merci à vous
    Bien amicalement

  16. #16
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Points : 91 220
    Points
    91 220
    Billets dans le blog
    20
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    if(isset(var_dump($tabLabelText)))


    Que tu débutes est une chose, que tu ne te poses aucune question concernant le code que tu écris en est une autre...
    Ce bout de code n'a aucun sens.

  17. #17
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2013
    Messages
    55
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 55
    Points : 27
    Points
    27
    Par défaut
    Bonjour c'est pas très gentil
    Citation Envoyé par Bovino Voir le message
    [/code]

    Que tu débutes est une chose, que tu ne te poses aucune question concernant le code que tu écris en est une autre...
    -Attaque facile
    - Défense rapide
    Voici une question:
    le fait d'écrire
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $_POST[$tabLabelText[0]]
    en place de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $_POST['$tabLabelText[0]']
    alors qu'il y a un champ nommé dans le formulaire ligne 799 ou est la logique implacable dans la réponse.
    Je ne suis pas quelqu'un de mauvaise volonté, j'ai testé comme je pouvais!

  18. #18
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Points : 91 220
    Points
    91 220
    Billets dans le blog
    20
    Par défaut
    Que ma réponse ne te semble pas gentille est une chose, mais elle est motivée par le fait que tu as été plusieurs fois alerté sur ta mauvaise utilisation de isset() et que tu n’aies manifestement pas pris la peine de te renseigner sur la façon correcte de l'utiliser !

    Concernant $_POST[$tabLabelText[0]], si, la réponse de k'amm était d'une logique transcendante car tu sais très bien que tu n'as aucun champ se nommant $tabLabelText[0] dans ton formulaire, donc tu cherches manifestement la variable POST reçue correspondant à la valeur de $tabLabelText[0], soit $_POST[$tabLabelText[0]] et non $_POST['$tabLabelText[0]'].
    Ensuite, si $_POST['$tabLabelText[0]'] ne contient pas la valeur attendue, on y est pour rien.

    Bref, en résumé, ce que j'ai dit peut-être un peu sèchement c'est qu'on est ici pour t'aider, ce qui implique un minimum de débogage, de recherches et de réflexion de ta part, et donc pas uniquement gober les réponses reçues, mais essayer de les comprendre et de les adapter à ton code.

  19. #19
    Nouveau membre du Club
    Profil pro
    Inscrit en
    Février 2013
    Messages
    55
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2013
    Messages : 55
    Points : 27
    Points
    27
    Par défaut
    Bon j'en suis là:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
     
    <?php if( isset($_POST['submit']) ){ // le formulaire a été posté
    $tab_cp=array(93,95,60,62,80,59,02,27,28,76,14,50); // Tableaux des codes postaux
    $select_email='0';
     
    if(!empty($_POST['$tabLabelText[0]']))
    {
      $cp=$_POST['$tabLabelText[0]'];
      $int_cp = intval(substr($cp,0,2)); //Troncature du code postal pour ne garder que les 2 premiers caracteres et transforme en entier
     
    	if (in_array($int_cp,$tab_cp)){
      $select_email='1'; // Si code postal est dans la liste on choisi cet email
        	}
       }
     
    if($select_email == '1'){
      $email="adresseA@gmail.com";// code postal dans la liste
     
    }else{
    	if( date("d") % 2 == 0 ) // nous sommes un jour pair
      $email="adresseA@gmail.com";
    else
      $email="adresseB@gmail.com";// nous sommes un jour impair
    }
      $formName="Devis campagne N°1"; 
      $emailSubject="Informations transmises par le formulaire";
     
    ?>
     
    <?php
    J'ai remplacé:
    if(isset par if(!empty
    enlevé les ' de chaque chiffres du tableau des CP
    C'est peut être à cause du champ texte, c'est pas mieux un champ menu déroulant avec tous les départements ?
    Je suis perdu là!

  20. #20
    Membre averti

    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2011
    Messages
    205
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Juin 2011
    Messages : 205
    Points : 409
    Points
    409
    Billets dans le blog
    1
    Par défaut
    Bon, on va passer sur le bordel innommable de ton code (des classes, du traitement, de l'affiche, le tout bien mélangé histoire de perdre la prochaine personne qui aura la triste tâche de maintenir / faire évoluer / débugger ce code) et sa longueur (868 lignes, rien que ça !).

    Voilà ton champ :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <input type="hidden" name="tabLabelText" value="<?php echo base64_encode(serialize($tabLabelText));?>" />
    Et sa récupération :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $tabLabelText=unserialize(base64_decode($_POST['tabLabelText']));
    Donc écrire $_POST['$tabLabelText[0]'] est une aberration puisque ton champs se nomme "tabLabelText" et non "$tabLabelText[0]" et qu'en plus tu l'as déjà récupéré plus haut.
    Normal du coup que, quoique tu fasses, ton test foire : ton $_POST n'a rien à faire là puisque ce que tu veux tester est déjà contenu dans $tabLabeltest (qui récupère la valeur désérialisée de ton POST)...du moins du peu que j'ai pu comprendre de ton code (qui est - une fois de plus - tout sauf lisible).

    Comme disait laurentSc, mets un var_dump histoire de mieux comprendre ce que tu fais.
    Et pour comprendre ce que fait cette fonction et comment l'utiliser : http://php.net/var_dump
    Par exemple :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    '$_POST['$tabLabelText[0]'] : '.var_dump($_POST['$tabLabelText[0]']);
    '$tabLabelText : '.var_dump($tabLabelText);
    '$_POST : '.var_dump($_POST);

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 3 123 DernièreDernière

Discussions similaires

  1. [PHP 5.4] rien ne s'affiche dans ma BD lors de l'envoi de formulaire
    Par cristelle1986 dans le forum Langage
    Réponses: 24
    Dernier message: 09/10/2014, 12h41
  2. Réponses: 13
    Dernier message: 24/05/2011, 20h38
  3. Réponses: 4
    Dernier message: 21/05/2011, 17h45
  4. Réponses: 1
    Dernier message: 03/01/2011, 09h25
  5. Réponses: 5
    Dernier message: 04/06/2009, 23h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo