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

AJAX Discussion :

[AJAX] Récupération de la valeur d'un select


Sujet :

AJAX

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Homme Profil pro
    Delphi
    Inscrit en
    Août 2006
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Eure et Loir (Centre)

    Informations professionnelles :
    Activité : Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 11
    Par défaut [AJAX] Récupération de la valeur d'un select
    Bonjour,

    J'ai utilisé ce tuto http://siddh.developpez.com/articles/ajax/ pour faire une liste liée. Tout fonctionne bien à l'affichage mais j'ai un souci quand j'envoie les valeurs du formulaire dans mon script php qui envoie les emails.

    Je n'arrive pas à récupérer la valeur de ma deuxième liste. Je pense qu'il me manque quelque chose sur le bouton d'envoi mais je n'arrive pas à trouver quoi.

    Je suis novice en javascript et j'ai déjà passé plusieurs heures à essayer de trouver une solution.

    Code du <Header>
    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
     
      <script type='text/javascript'>
     
    			function getXhr(){
                                    var xhr = null; 
    				if(window.XMLHttpRequest) // Firefox et autres
    				   xhr = new XMLHttpRequest(); 
    				else if(window.ActiveXObject){ // Internet Explorer 
    				   try {
    			                xhr = new ActiveXObject("Msxml2.XMLHTTP");
    			            } catch (e) {
    			                xhr = new ActiveXObject("Microsoft.XMLHTTP");
    			            }
    				}
    				else { // XMLHttpRequest non supporté par le navigateur 
    				   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
    				   xhr = false; 
    				} 
                                    return xhr;
    			}
     
    			/**
    			* Méthode qui sera appelée sur le click du bouton
    			*/
    			function go(){
    				var xhr = getXhr();
    				// On défini ce qu'on va faire quand on aura la réponse
    				xhr.onreadystatechange = function(){
    					// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    					if(xhr.readyState == 4 && xhr.status == 200){
    						leselect = xhr.responseText;
    						// On se sert de innerHTML pour rajouter les options a la liste
    						document.getElementById('ville').innerHTML = leselect;
    					}
    				}
     
    				// Ici on va voir comment faire du post
    				xhr.open("POST","DeptPays.php",true);
    				// ne pas oublier ça pour le post
    				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    				// ne pas oublier de poster les arguments
    				// ici, l'id de l'auteur
    				sel = document.getElementById('dept');
    				iddept = sel.options[sel.selectedIndex].value;
    				xhr.send("iddept="+iddept);
    			}
    		</script>
    Code du <Body>

    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
    <form name="formu" onsubmit="return verifierMail(this.elements['Email']);" action="Script-formulaire/formulaire-contact.php" method="post">
     
                                <tr valign="middle">
                                    <td height="21" colspan="2" align="left" background="images/Fond/fond_titre_presse.jpg"><strong class="STitre">Vous souhaitez &ecirc;tre contact&eacute; par GESTIMUM&nbsp;:</strong></td>
                                </tr>
                                <tr valign="middle">
                                    <td height="9" colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Devenir Centre de Solutions">
                                        <span class="TexteFicheP">Vous souhaitez devenir Centre de Solutions GESTIMUM</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Projet d'&eacute;quipement">
                                        <span class="TexteFicheP">Vous &ecirc;tes une PME/PMI et vous avez un projet d'&eacute;quipement</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="10" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Expert Comptable/Commissaire aux comptes">          
                                        <span class="TexteFicheP">Vous &ecirc;tes Expert Comptable / Commissaire aux comptes et souhaitez avoir plus d'informations sur notre offre</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Int&eacute;gration de solution">          
                                        <span class="TexteFicheP">Vous &ecirc;tes &eacute;diteur d&rsquo;une solution verticale et recherchez un progiciel de comptabilit&eacute; capable de s&rsquo;int&eacute;grer &agrave; votre offre</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Journaliste">
                                        <span class="TexteFicheP">Vous &ecirc;tes Journaliste et cherchez des informations sur GESTIMUM</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Recrutement">          
                                        <span class="TexteFicheP">Vous &ecirc;tes &agrave; la recherche d&rsquo;une opportunit&eacute; professionnelle</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Demonstration">
                                        <span class="TexteFicheP">Vous souhaitez avoir une d&eacute;monstration de Gestimum</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="10" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Autres">
                                        <span class="TexteFicheP">Autres sujets</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="19" colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle">
                                    <td height="19" colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle"> 
                                    <td height="19" colspan="2" align="left" valign="top">
                                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td width="27%" height="25" align="left" valign="middle" class="TexteFicheP">Nom de l'entreprise*&nbsp;:</td>
                                                <td width="28%" height="20" align="left" valign="middle"><input name="Nom-de-l-entreprise" type="text" class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td width="27%" height="25" align="left" valign="middle" class="TexteFicheP">Pr&eacute;nom / Nom* : </td>
                                                <td height="25" align="left" valign="middle"><input name="Prenom-Nom" type="text" class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">T&eacute;l&eacute;phone (indicatif  du pays svp)* :</td>
                                                <td height="25" align="left" valign="middle"><input name="Telephone" type="text" class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">Email* :</td>
                                                <td height="25" align="left" valign="middle"><input name="Email" type="text"  class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">Votre localisation* : </td>
                                                <td height="25" colspan="2" align="left" valign="middle">
                                                <select name='dept' id='dept' onchange='go()'>
    											 <option value='-1'>Aucun</option>
    												<?php
                                                                                                            $select = "SELECT CODE_LOCALISATION, LOCALISATION FROM localisation ORDER BY CODE_LOCALISATION";
                                                                                                            $res = mysql_query($select) or die('Erreur SQL !<br>'.$select.'<br>'.mysql_error());
                                                                                                            while($row = mysql_fetch_assoc($res))
                                                                                                            {
                                                                                                            echo "<option value='".$row["CODE_LOCALISATION"]."'>".$row["LOCALISATION"]."</option>";
                                                                                                            }
                                                                                                    ?>
    							 				</select>
     
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">Votre D&eacute;partement&nbsp;ou Pays* : </td>
                                                <td height="25" colspan="2" align="left" valign="middle">
                                                 <div id='ville' style='display:inline'>
                                 				<select name='ville'>
    					                         <option value='-1'>Choisir un dept ou un pays</option>
    				                            </select>
    											 </div>
     
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="19" colspan="2" align="left" class="pied">* champs obligatoires</td>
                                </tr>
                                <tr>
                                    <td height="20" colspan="2" align="center"><img src="images/Decor/barre.gif" width="775" height="1" border="0"></td>
                                </tr>
                                <tr>
                                    <td height="19" colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td height="168" colspan="2" align="left" valign="middle">
                                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <td align="left" valign="middle"><p><span class="TexteFicheP">Pr&eacute;cisez votre demande (facultatif) :</span></p>
                                                    <p>
                                                        <textarea name="Description-de-la-demande" cols="100" rows="7"  class="TexteFicheP" id="Commentaires"></textarea>
                                                    </p>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="9" colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                  <td height="10" colspan="2" align="center" valign="middle"><a href="#" onClick="document.getElementById('captcha').src = '../crypt/securimage_show.php?' + Math.random(); return false"></a></td>
                                </tr>
                                <tr>
                                  <td height="9" align="center" valign="middle"><img id="captcha" src="crypt/securimage_show.php" alt="CAPTCHA Image" /></td>
                                  <td height="19" rowspan="2" align="left" valign="middle"><span class="TexteFicheP">Taper le code ci-contre :</span>                                <input type="text" name="captcha_code" size="10" maxlength="6" /></td>
                                </tr>
                                <tr>
                                  <td height="10" align="center" valign="middle"><a href="#" class="TexteFicheP" onClick="document.getElementById('captcha').src = 'crypt/securimage_show.php?' + Math.random(); return false">Recharger l'image</a></td>
                                </tr>
                                <tr>
                                  <td colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                  <td height="19" colspan="2" align="center"><input  type="submit" value="Envoyer" class="TexteFicheP"  />
    &nbsp;
    <input name="input" type="reset" value="Effacer" class="TexteFicheP"/></td>
    							</tr>
    							</form>
    LE code de ma seconde en php

    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
    <?php
     
     include ('Fichier_connect/x.php');
     
      echo "<select name='ville' id='ville'>";
            if(isset($_POST["iddept"]))
               {
                    $sql = 'SELECT code, pays FROM pays WHERE code_localisation = "' . $_POST['iddept'] . '" ORDER BY code';
                    $res = mysql_query($sql) or die('Erreur : <br>' . $sql . '<br>' . mysql_error());
                    while($row = mysql_fetch_assoc($res))
                    {
                            echo "<option value='".$row["code"]."'>".$row["pays"]."</option>";
                    }
               }
            echo "</select>";
    ?>
    Je vous remercie d'avance pour aide.

  2. #2
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    Bonsoir,

    IE va les confondre,
    <div id='ville' style='display:inline'>
    <select name='ville'>
    Et avec ça, tu aura le même id pour 2 éléments (div conteneur et select)
    echo "<select name='ville' id='ville'>";
    A+.

  3. #3
    Membre averti
    Homme Profil pro
    Delphi
    Inscrit en
    Août 2006
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Eure et Loir (Centre)

    Informations professionnelles :
    Activité : Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 11
    Par défaut
    Bonjour,

    J'ai fait les modifs mais je suis toujours sur le même problème, dès que j'envoi les données du formulaire avec le bouton envoyer, je ne récupére pas la donnée de la 2e liste.

    Si quelqu'un a une idée, je suis preneur.

    En vous remerciant d'avance pour votre aide.

  4. #4
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    Bonjour,

    Peux-tu nous monter ton nouveau code et comment tu récupères les données.

    A+.

  5. #5
    Membre averti
    Homme Profil pro
    Delphi
    Inscrit en
    Août 2006
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Eure et Loir (Centre)

    Informations professionnelles :
    Activité : Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 11
    Par défaut
    Tu trouveras ci-dessous mon nouveau code :

    Dans le header
    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
     
     <script type='text/javascript'>
     
    			function getXhr(){
                                    var xhr = null; 
    				if(window.XMLHttpRequest) // Firefox et autres
    				   xhr = new XMLHttpRequest(); 
    				else if(window.ActiveXObject){ // Internet Explorer 
    				   try {
    			                xhr = new ActiveXObject("Msxml2.XMLHTTP");
    			            } catch (e) {
    			                xhr = new ActiveXObject("Microsoft.XMLHTTP");
    			            }
    				}
    				else { // XMLHttpRequest non supporté par le navigateur 
    				   alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
    				   xhr = false; 
    				} 
                                    return xhr;
    			}
     
    			/**
    			* Méthode qui sera appelée sur le click du bouton
    			*/
    			function go(){
    				var xhr = getXhr();
    				// On défini ce qu'on va faire quand on aura la réponse
    				xhr.onreadystatechange = function(){
    					// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
    					if(xhr.readyState == 4 && xhr.status == 200){
    						leselect = xhr.responseText;
    						// On se sert de innerHTML pour rajouter les options a la liste
    						document.getElementById('divville').innerHTML = leselect;
    					}
    				}
     
    				// Ici on va voir comment faire du post
    				xhr.open("POST","DeptPays.php",true);
    				// ne pas oublier ça pour le post
    				xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    				// ne pas oublier de poster les arguments
    				// ici, l'id de l'auteur
    				sel = document.getElementById('dept');
    				iddept = sel.options[sel.selectedIndex].value;
    				xhr.send("iddept="+iddept);
    			}
    		</script>
    Le formulaire dans le body
    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
     
     
     
    <form name="formu" onsubmit="return verifierMail(this.elements['Email']);" action="Script-formulaire/formulaire-contact-test.php" method="post">
                                <tr valign="middle">
                                    <td height="21" colspan="2" align="left" background="images/Fond/fond_titre_presse.jpg"><strong class="STitre">Vous souhaitez &ecirc;tre contact&eacute; par GESTIMUM&nbsp;:</strong></td>
                                </tr>
                                <tr valign="middle">
                                    <td height="9" colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Devenir Centre de Solutions">
                                        <span class="TexteFicheP">Vous souhaitez devenir Centre de Solutions GESTIMUM</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Projet d'&eacute;quipement">
                                        <span class="TexteFicheP">Vous &ecirc;tes une PME/PMI et vous avez un projet d'&eacute;quipement</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="10" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Expert Comptable/Commissaire aux comptes">          
                                        <span class="TexteFicheP">Vous &ecirc;tes Expert Comptable / Commissaire aux comptes et souhaitez avoir plus d'informations sur notre offre</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Int&eacute;gration de solution">          
                                        <span class="TexteFicheP">Vous &ecirc;tes &eacute;diteur d&rsquo;une solution verticale et recherchez un progiciel de comptabilit&eacute; capable de s&rsquo;int&eacute;grer &agrave; votre offre</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Journaliste">
                                        <span class="TexteFicheP">Vous &ecirc;tes Journaliste et cherchez des informations sur GESTIMUM</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Recrutement">          
                                        <span class="TexteFicheP">Vous &ecirc;tes &agrave; la recherche d&rsquo;une opportunit&eacute; professionnelle</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Demonstration">
                                        <span class="TexteFicheP">Vous souhaitez avoir une d&eacute;monstration de Gestimum</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="10" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Autres">
                                        <span class="TexteFicheP">Autres sujets</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="19" colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle">
                                    <td height="19" colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle"> 
                                    <td height="19" colspan="2" align="left" valign="top">
                                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td width="27%" height="25" align="left" valign="middle" class="TexteFicheP">Nom de l'entreprise*&nbsp;:</td>
                                                <td width="28%" height="20" align="left" valign="middle"><input name="Nom-de-l-entreprise" type="text" class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td width="27%" height="25" align="left" valign="middle" class="TexteFicheP">Pr&eacute;nom / Nom* : </td>
                                                <td height="25" align="left" valign="middle"><input name="Prenom-Nom" type="text" class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">T&eacute;l&eacute;phone (indicatif  du pays svp)* :</td>
                                                <td height="25" align="left" valign="middle"><input name="Telephone" type="text" class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">Email* :</td>
                                                <td height="25" align="left" valign="middle"><input name="Email" type="text"  class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">Votre localisation* : </td>
                                                <td height="25" colspan="2" align="left" valign="middle">
                                                <select name='dept' id='dept' onchange='go()'>
    											 <option value='-1'>Aucun</option>
    												<?php
                                                                                                            $select = "SELECT CODE_LOCALISATION, LOCALISATION FROM localisation ORDER BY CODE_LOCALISATION";
                                                                                                            $res = mysql_query($select) or die('Erreur SQL !<br>'.$select.'<br>'.mysql_error());
                                                                                                            while($row = mysql_fetch_assoc($res))
                                                                                                            {
                                                                                                            echo "<option value='".$row["CODE_LOCALISATION"]."'>".$row["LOCALISATION"]."</option>";
                                                                                                            }
                                                                                                    ?>
    							 				</select>
     
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">Votre D&eacute;partement&nbsp;ou Pays* : </td>
                                                <td height="25" colspan="2" align="left" valign="middle">
                                                 <div id='divville' style='display:inline'>
                                 				  <select name='selectville'>
    					                           <option value='-1'>Choisir un dept ou un pays</option>
    				                              </select>
    											 </div>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="19" colspan="2" align="left" class="pied">* champs obligatoires</td>
                                </tr>
                                <tr>
                                    <td height="20" colspan="2" align="center"><img src="images/Decor/barre.gif" width="775" height="1" border="0"></td>
                                </tr>
                                <tr>
                                    <td height="19" colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td height="168" colspan="2" align="left" valign="middle">
                                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <td align="left" valign="middle"><p><span class="TexteFicheP">Pr&eacute;cisez votre demande (facultatif) :</span></p>
                                                    <p>
                                                        <textarea name="Description-de-la-demande" cols="100" rows="7"  class="TexteFicheP" id="Commentaires"></textarea>
                                                    </p>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="9" colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                  <td height="10" colspan="2" align="center" valign="middle"><a href="#" onClick="document.getElementById('captcha').src = '../crypt/securimage_show.php?' + Math.random(); return false"></a></td>
                                </tr>
                                <tr>
                                  <td height="9" align="center" valign="middle"><img id="captcha" src="crypt/securimage_show.php" alt="CAPTCHA Image" /></td>
                                  <td height="19" rowspan="2" align="left" valign="middle"><span class="TexteFicheP">Taper le code ci-contre :</span>                                <input type="text" name="captcha_code" size="10" maxlength="6" /></td>
                                </tr>
                                <tr>
                                  <td height="10" align="center" valign="middle"><a href="#" class="TexteFicheP" onClick="document.getElementById('captcha').src = 'crypt/securimage_show.php?' + Math.random(); return false">Recharger l'image</a></td>
                                </tr>
                                <tr>
                                  <td colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                  <td height="19" colspan="2" align="center"><input  type="submit" value="Envoyer" class="TexteFicheP"/>
    &nbsp;
    <input name="input" type="reset" value="Effacer" class="TexteFicheP"/></td>
    Le code qui génére la 2nd liste
    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
     
    <?php
     
     include ('Fichier_connect/x.php');
     
      echo "<select name='selectville' id='selectville'>";
            if(isset($_POST["iddept"]))
               {
                    $sql = 'SELECT code, pays FROM pays WHERE code_localisation = "' . $_POST['iddept'] . '" ORDER BY code';
                    $res = mysql_query($sql) or die('Erreur : <br>' . $sql . '<br>' . mysql_error());
                    while($row = mysql_fetch_assoc($res))
                    {
                            echo "<option value='".$row["code"]."'>".$row["pays"]."</option>";
                    }
               }
            echo "</select>";
    ?>
    Et le code qui récupére et traite l'envoi des email
    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
     
    <?php
    session_start();
     
    include_once $_SERVER['DOCUMENT_ROOT'] . '../crypt/securimage.php';
     
    $securimage = new Securimage();
     
    include ('../Fichier_connect/x.php');
     
    $Type = trim($_POST["type"]);
    $RS = trim($_POST["Nom-de-l-entreprise"]);
    $Contact = trim($_POST["Prenom-Nom"]);
    $Tel = trim($_POST["Telephone"]);
    $Email = trim($_POST["Email"]);
    $Localisation = trim($_POST["dept"]);
    $Description = trim($_POST["Description-de-la-demande"]);
    $Pays = trim($_POST["selectville"]);
     
     
    if ($securimage->check($_POST['captcha_code']) == false) {
     
      echo "<script>alert(\"Le code que vous venez de taper n'est pas bon. Veuillez le resaisir.\")</script>"; 
      echo '<META HTTP-EQUIV="Refresh" CONTENT="3;URL= ''">';
    }
    else
    {
     if (!empty($Type) && !empty($RS) && !empty($Contact) && !empty($Email) && !empty($Tel) && !empty($Localisation) /*&& !empty($Pays)*/)
     {  
     
        if ($Localisation == 'FR')
        {
          $sql = "SELECT MAX(Adresse_Email) as 'Email' FROM departements WHERE dept='$Pays' GROUP BY CIAL";
          $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
          $data = mysql_fetch_array($req);  
          $TO = $data['Email'];
        }
        else
        {
          $TO = '';
        }
        $TO .= '';
     
        $sql2 = "SELECT PAYS FROM pays WHERE CODE='$Pays'";
        $req2 = mysql_query($sql2) or die('Erreur SQL !<br>'.$sql2.'<br>'.mysql_error());
        $data2 = mysql_fetch_array($req2); 
     
        $sql3 = "SELECT LOCALISATION FROM localisation WHERE CODE_LOCALISATION='$Localisation'";
        $req3 = mysql_query($sql3) or die('Erreur SQL !<br>'.$sql3.'<br>'.mysql_error());
        $data3 = mysql_fetch_array($req3);   
     
        $h = "From: ".$RS." <".$Email.">"."\r\n";
        $subject = "A recontacter";
     
        $message =" Demande : ".$Type."\n Raison sociale : ".$RS."\n Prenom/Nom : ".$Contact."\n Email : ".$Email."\n Téléphone : ".$Tel."\n Localisation : ".$data3['LOCALISATION']."\n Dept ou Pays : ".$data2['PAYS']."\n Description : ".$Description;
     
     
      mail($TO, $subject, $message, $h);
     
      echo "<script>alert(\"Nous avons bien reçu votre message et vous remercions de l’intérêt que vous portez à notre société. Nous allons traiter votre demande dans les plus brefs délais.\")</script>"; 
      echo '<META HTTP-EQUIV="Refresh" CONTENT="3;URL= ''">';
      //Header("Location: http://www.gestimum.com/accueil.php");
     }
     else 
     {
      echo "<script>alert(\"Vous devez remplir tous les champs obligatoires\")</script>"; 
      echo '<META HTTP-EQUIV="Refresh" CONTENT="3;URL= ''"> ';
      /*echo "<script>alert('Vous n'avez pas rempli tous les champs obligatoires');</script>"; 
      
      Header("Location: http://www.gestimum.com/Contacts-test.php");*/
     } 
    }
    ?>

  6. #6
    Membre averti
    Homme Profil pro
    Delphi
    Inscrit en
    Août 2006
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Eure et Loir (Centre)

    Informations professionnelles :
    Activité : Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 11
    Par défaut
    J'ai progressé dans mon problème, j'ai repris un peu tout le code. Maintenant, j'envoi bien tout sous IE mais j'ai toujours un le même problème avec FireFox.

    Je vous mets mon nouveau code.

    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
     
    <?php
     
    include ('Fichier_connect/x.php');
     
    // Construction de la liste déroulante des départements du pays sélectionné
     
    if ($_GET['listedepartements'])
    {
        $html = '<select name="ville" id="ville" class="TexteFicheP">';
        $html .= '<option value="00">Selectionnez votre Département ou Pays</option>';
        
        $select = 'SELECT code, pays FROM pays WHERE code_localisation = "' . $_GET['pays'] . '" ORDER BY code';
        $cursor = mysql_query($select) or die('Erreur : <br>' . $select . '<br>' . mysql_error());
        while ($row = mysql_fetch_array($cursor))
            $html .= '<option value="' . $row['code'] . '">' . $row['pays'] . '</option>';
        
        $html .= '</select>'; 
        
        echo mb_convert_encoding($html, "UTF-8", "ISO-8859-15");  
        
        return;
    }
     
    ?>
     
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"  "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
             <script type="text/javascript">
     
        function createXMLHttpRequest()
        {
            // XMLHttpRequest
            if (window.XMLHttpRequest)
                return new XMLHttpRequest();
     
            // ActiveXObject
            if (window.ActiveXObject)
            {
                var names = ["Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.3.0", "Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
                for (var i in names)
                {
                    try
                    { 
                        return new ActiveXObject(names[i]);
                    }
                    catch(e)
                    {
                    }
                }
            }
     
            // null
            window.alert("Votre navigateur ne prend pas en charge XMLHTTPRequest.");
            return null;
        }
     
        function sendXMLHttpRequest(url, idElement)
        {
            // Recherche de l'élément HTML
            var element = document.getElementById(idElement);
            if (element == null)
            {
                window.alert("sendXMLHttpRequest : l'appel à getElementById avec id = " + id + " a échoué.");
                return;
            }
     
            // Instanciation d'un XMLHttpRequest
            var XHR = createXMLHttpRequest();
            if (XHR == null)
            {
                window.alert("sendXMLHttpRequest : l'appel à createXMLHttpRequest a échoué.");
                return;
            }
     
            // send
            XHR.open("POST", url, true);
            XHR.onreadystatechange = function()
            {
                if (XHR.readyState == 4)
                element.innerHTML = XHR.responseText;
            }
            XHR.send(null);
        }
     
        function loadDepartements(pays, idElement)
        {
            //window.alert("loadDepartements:" + pays + "," + idElement);
            sendXMLHttpRequest("Contacts.php?listedepartements=1&pays=" + pays, idElement);
        }
    </script>
     
        </head>
        <body >
            <table width="975" border="0" align="center" cellpadding="0" cellspacing="0" id="tblgen">
                <tr align="center" valign="bottom" >
                    <td colspan="3" align="left" valign="bottom">
                        <table width="100%" height="144" border="0" cellpadding="0" cellspacing="0" background="images/Pont/ponte_vasco_e.jpg" >
                            <tr>
                                <td width="96%" colspan="2" align="center" valign="top"></td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr align="center" valign="bottom" >
                    <td height="19" colspan="3" align="left" valign="bottom">
                    </td>
                </tr>
                <tr align="center" valign="bottom" >
                    <td height="5" colspan="3" align="left" valign="middle">
     
                    </td>
                </tr>
                <tr align="center" valign="bottom" >
                    <td height="5" colspan="3" valign="bottom"></td>
                </tr>
    			    <td width="12" rowspan="38" align="center" valign="top" >&nbsp;</td>
                    <td width="12" rowspan="38" align="center" valign="top" >&nbsp;</td>
                    <td width="776" rowspan="37" align="left" valign="top" >
                        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                            <form name="formu" onsubmit="return verifierMail(this.elements['Email']);" action="Script-formulaire/formulaire-contact.php" method="post">
                                <tr valign="middle">
                                    <td height="37" colspan="2" align="left">
                                        <table width="639" height="100%" border="0" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td align="left" valign="middle"><span class="TitreFicheP">Contacter GESTIMUM :</span></td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td width="44%" colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle">
                                    <td height="10" colspan="2" align="center">
     
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle">
                                    <td height="21" colspan="2" align="left" background="images/Fond/fond_titre_presse.jpg"><strong class="STitre">Vous souhaitez &ecirc;tre contact&eacute; par GESTIMUM&nbsp;:</strong></td>
                                </tr>
                                <tr valign="middle">
                                    <td height="9" colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Devenir Centre de Solutions">
                                        <span class="TexteFicheP">Vous souhaitez devenir Centre de Solutions GESTIMUM</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Projet d'&eacute;quipement">
                                        <span class="TexteFicheP">Vous &ecirc;tes une PME/PMI et vous avez un projet d'&eacute;quipement</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="10" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Expert Comptable/Commissaire aux comptes">          
                                        <span class="TexteFicheP">Vous &ecirc;tes Expert Comptable / Commissaire aux comptes et souhaitez avoir plus d'informations sur notre offre</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Int&eacute;gration de solution">          
                                        <span class="TexteFicheP">Vous &ecirc;tes &eacute;diteur d&rsquo;une solution verticale et recherchez un progiciel de comptabilit&eacute; capable de s&rsquo;int&eacute;grer &agrave; votre offre</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Journaliste">
                                        <span class="TexteFicheP">Vous &ecirc;tes Journaliste et cherchez des informations sur GESTIMUM</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Recrutement">          
                                        <span class="TexteFicheP">Vous &ecirc;tes &agrave; la recherche d&rsquo;une opportunit&eacute; professionnelle</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="5" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Demonstration">
                                        <span class="TexteFicheP">Vous souhaitez avoir une d&eacute;monstration de Gestimum</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="10" colspan="2" align="left"><input name="type" type="radio" class="TexteFicheP" value="Autres">
                                        <span class="TexteFicheP">Autres sujets</span>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="19" colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle">
                                    <td height="19" colspan="2" align="left">&nbsp;</td>
                                </tr>
                                <tr valign="middle"> 
                                    <td height="19" colspan="2" align="left" valign="top">
                                        <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td width="27%" height="25" align="left" valign="middle" class="TexteFicheP">Nom de l'entreprise*&nbsp;:</td>
                                                <td width="28%" height="20" align="left" valign="middle"><input name="Nom-de-l-entreprise" type="text" class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td width="27%" height="25" align="left" valign="middle" class="TexteFicheP">Pr&eacute;nom / Nom* : </td>
                                                <td height="25" align="left" valign="middle"><input name="Prenom-Nom" type="text" class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">T&eacute;l&eacute;phone (indicatif  du pays svp)* :</td>
                                                <td height="25" align="left" valign="middle"><input name="Telephone" type="text" class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">Email* :</td>
                                                <td height="25" align="left" valign="middle"><input name="Email" type="text"  class="TexteFicheP" size="30" /></td>
                                                <td width="45%" class="Style126">&nbsp;</td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">Votre localisation* : </td>
                                                <td height="25" colspan="2" align="left" valign="middle">
                                                    <select name="dept" id="dept" onChange="loadDepartements(this.value, 'affVille');" class="TexteFicheP">
                                                        <option value="00">Selectionnez votre localisation</option>
    <?php
    $select = "SELECT CODE_LOCALISATION, LOCALISATION FROM localisation ORDER BY CODE_LOCALISATION";
    $cursor = mysql_query($select) or die('Erreur SQL !<br>'.$select.'<br>'.mysql_error());
    while ($row = mysql_fetch_array($cursor))
    {
    ?>
                                                        <option value="<?php echo ($row['CODE_LOCALISATION']); ?>"><?php echo ($row['LOCALISATION']); ?></option>
    <?php
    }
    ?>
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td height="25" align="left" valign="middle" class="TexteFicheP">Votre D&eacute;partement&nbsp;ou Pays* : </td>
                                                <td height="25" colspan="2" align="left" valign="middle">
                                                    <div id="affVille" name="affVille"></div>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr valign="middle">
                                    <td height="19" colspan="2" align="left" class="pied">* champs obligatoires</td>
                                </tr>
                                <tr>
                                    <td height="20" colspan="2" align="center"><img src="images/Decor/barre.gif" width="775" height="1" border="0"></td>
                                </tr>
                                <tr>
                                    <td height="19" colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td height="168" colspan="2" align="left" valign="middle">
                                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                            <tr>
                                                <td align="left" valign="middle"><p><span class="TexteFicheP">Pr&eacute;cisez votre demande (facultatif) :</span></p>
                                                    <p>
                                                        <textarea name="Description-de-la-demande" cols="100" rows="7"  class="TexteFicheP" id="Commentaires"></textarea>
                                                    </p>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td height="9" colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                  <td height="10" colspan="2" align="center" valign="middle"><a href="#" onClick="document.getElementById('captcha').src = '../crypt/securimage_show.php?' + Math.random(); return false"></a></td>
                                </tr>
                                <tr>
                                  <td height="9" align="center" valign="middle"><img id="captcha" src="crypt/securimage_show.php" alt="CAPTCHA Image" /></td>
                                  <td height="19" rowspan="2" align="left" valign="middle"><span class="TexteFicheP">Taper le code ci-contre :</span>                                <input type="text" name="captcha_code" size="10" maxlength="6" /></td>
                                </tr>
                                <tr>
                                  <td height="10" align="center" valign="middle"><a href="#" class="TexteFicheP" onClick="document.getElementById('captcha').src = 'crypt/securimage_show.php?' + Math.random(); return false">Recharger l'image</a></td>
                                </tr>
                                <tr>
                                  <td colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                  <td height="19" colspan="2" align="center"><input  type="submit" value="Envoyer" class="TexteFicheP"  />
    &nbsp;
    <input name="input" type="reset" value="Effacer" class="TexteFicheP"/></td>
                                </tr>
                                <tr>
                                  <td height="19" colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td height="20" colspan="2" align="center"><a href="" onMouseOver="MM_showHideLayers('produits','','hide','services','','hide','partenaire_distri','','hide','partenaires_edit','','hide','culture_valeur','','hide')"><img src="images/Decor/barre.gif" width="775" height="1" border="0"></a></td>
                                </tr>
                                <tr>
                                    <td height="19" colspan="2" align="center">&nbsp;</td>
                                </tr>
                                <tr>
                                    <td height="24" colspan="2" align="center" valign="middle" bordercolor="FFFFFF">&nbsp;</td>
                                </tr>
                            </form>
                        </table>
                    </td>
                </tr>
     
            </table>
        </body>
    </html>
    Le code pour l'envoi du mail
    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
     
    <?php
    session_start();
     
    include_once $_SERVER['DOCUMENT_ROOT'] . '../crypt/securimage.php';
     
    $securimage = new Securimage();
     
    include ('../Fichier_connect/x.php');
     
    $Type = trim($_POST["type"]);
    $RS = trim($_POST["Nom-de-l-entreprise"]);
    $Contact = trim($_POST["Prenom-Nom"]);
    $Tel = trim($_POST["Telephone"]);
    $Email = trim($_POST["Email"]);
    $Localisation = trim($_POST["dept"]);
    $Description = trim($_POST["Description-de-la-demande"]);
    $Pays = $Pays = trim($_POST["ville"]);
     
     
    if ($securimage->check($_POST['captcha_code']) == false) {
     
      echo "<script>alert(\"Le code que vous venez de taper n'est pas bon. Veuillez le resaisir.\")</script>"; 
      echo '<META HTTP-EQUIV="Refresh" CONTENT="3;URL= http://www.monsite.com">';
    }
    else
    {
     if (!empty($Type) && !empty($RS) && !empty($Contact) && !empty($Email) && !empty($Tel) && !empty($Localisation))
     {  
       
        if ($Localisation == 'FR')
        {
          $sql = "SELECT MAX(Adresse_Email) as 'Email' FROM departements WHERE dept='$Pays' GROUP BY CIAL";
          $req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
          $data = mysql_fetch_array($req);  
          $TO = $data['Email'];
        }
        else
        {
          $TO = "example@mail.com";
        }
        
            if (empty($TO)) {$TO = "example@mail.com";}
            
        $sql2 = "SELECT PAYS FROM pays WHERE CODE='$Pays'";
        $req2 = mysql_query($sql2) or die('Erreur SQL !<br>'.$sql2.'<br>'.mysql_error());
        $data2 = mysql_fetch_array($req2); 
      
        $sql3 = "SELECT LOCALISATION FROM localisation WHERE CODE_LOCALISATION='$Localisation'";
        $req3 = mysql_query($sql3) or die('Erreur SQL !<br>'.$sql3.'<br>'.mysql_error());
        $data3 = mysql_fetch_array($req3);   
         
        $h = "From: ".$RS." <".$Email.">"."\r\n";
            $h .= "Cc:example@mail.com \n";
            $h .= "Reply-To: ".$Email." \n";
     
        if (empty($h)) {$h="From: example@mail.com";}
            
            $subject = "A recontacter";
        
        $message =" Demande : ".$Type."\n Raison sociale : ".$RS."\n Prenom/Nom : ".$Contact."\n Email : ".$Email."\n Téléphone : ".$Tel."\n Localisation : ".$data3['LOCALISATION']."\n Dept ou Pays : ".$data2['PAYS']."\n Description : ".$Description;
         
             if (empty($message)) {$message="Message non reçu";}
      
      mail($TO, $subject, $message, $h);
      
      echo "<script>alert(\"Nous avons bien reçu votre message et vous remercions de l’intérêt que vous portez à notre société. Nous allons traiter votre demande dans les plus brefs délais.\")</script>"; 
      echo '<META HTTP-EQUIV="Refresh" CONTENT="3;URL= http://www.monsite.com">';
     
     }
     else 
     {
      echo "<script>alert(\"Vous devez remplir tous les champs obligatoires\")</script>"; 
      echo '<META HTTP-EQUIV="Refresh" CONTENT="3;URL= http://www.monsite.com"> ';
      
     } 
    }
    ?>
    Si vous voyez ce qui peut provoqué l'erreur avec FireFox et pas IE.

    Je vous remercie pour votre aide.

  7. #7
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    Bonsoir,

    XHR.open("POST", url, true);
    Comme tu passes la variable en URL, remplace POST par GET.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     XHR.open("GET", url, true);
    PS: pour la methode POST, tu dois ajouter un header
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    XHR.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    A+.

  8. #8
    Membre averti
    Homme Profil pro
    Delphi
    Inscrit en
    Août 2006
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Eure et Loir (Centre)

    Informations professionnelles :
    Activité : Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 11
    Par défaut
    Bonjour,

    J'ai essayé les 2 méthodes en mettant GET ou POST mais j'ai toujours le même problème, je ne récupére rien avec FireFox de ma 2e liste déroulante.

    Je ne sais pas quoi faire.

  9. #9
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Par défaut
    Si tu envoies par GET, du coté serveur tu dois les récupérer avec $_GET, mais si tu utilises POST, tu dois sérialiser les variables et les mettre en paramètre dans send.
    Montre nous ton présent code.

    A+.

  10. #10
    Membre averti
    Homme Profil pro
    Delphi
    Inscrit en
    Août 2006
    Messages
    11
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Eure et Loir (Centre)

    Informations professionnelles :
    Activité : Delphi
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Août 2006
    Messages : 11
    Par défaut
    Bonjour,

    J'ai trouvé d'où venait mon problème, et du coup je me trouve un peu con , j'avais juste un petit problème avec ma balise html <form></form> qui était mal placé dans mon code. IE est vraiment trop permissif. Et une grosse perte de temps pour pas grand chose au final.

    En tout cas merci pour ton aide.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Récupération de la valeur d'un "SELECT.."
    Par Tintou dans le forum VBA Access
    Réponses: 4
    Dernier message: 21/05/2007, 19h43
  2. Récupération de la valeur textuelle du select et non de la valeur
    Par kenny49 dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 12/04/2007, 11h27
  3. [AJAX] Récupération d'une valeur en retour d'un php
    Par lodan dans le forum Général JavaScript
    Réponses: 6
    Dernier message: 08/02/2007, 21h18
  4. [Ajax ] Recuperation de la valeur d'un select pour traitemen
    Par NeHuS dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 14/02/2006, 15h50
  5. récupération de la valeur d'un select
    Par kcizth dans le forum Langage
    Réponses: 2
    Dernier message: 10/01/2006, 10h21

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