Formulaire envoie condition

Mopire Messages postés 25 Statut Membre -  
mpmp93 Messages postés 7217 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
J'ai un formulaire où dedans il y a deux boutons radio dedans. Selon si on clique sur l'un ou l'autre bouton radio le reste du formulaire est différent. Le formulaire à en action la page envoie_inscription.php. Dans cette page je veux vérifier si il ne manque pas de champs à remplir avec des if (empty($nom_entreprise). Mais le problème qui m'arrive est comment faire pour faire que si c'est cette partie du formulaire ben vérifier cette partie, si c'est l'autre l'autre partie.

Je vous donne mon formulaire.php

<table class="BORDURE_FORMULAIRE" width="722" border="0" cellpadding="0" cellspacing="0" bgcolor="#74777c">
        	<tr>
            	<td width="722">
                    <table width="720" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                          <td width="30">&nbsp;</td>
                          <td width="240">&nbsp;</td>
                          <td width="238">&nbsp;</td>
						</tr>
                        <tr>
                          <td width="30">&nbsp;</td>
                          <td width="240" class="FORMULAIRE_ENVOI"><strong>Inscription</strong></td>
                          <td width="238">&nbsp;</td>
						</tr>   
						<tr>

                            <form method="post" action="envoie_inscription.php">
								<p>
								<table width="508" border="0" cellpadding="0" cellspacing="0">
                                  <br /><br/><tr >
                                      <td width="22">&nbsp;</td>
                                      <td width="240"><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong>Etes-vous un fournisseur ou une administration?</strong></label></td>
                                      <td width="238"><input type="radio" name="etape" value="fournisseur" id="fournisseur" /> <label for="fournisseur ">fournisseur    </label><input type="radio" name="etape" value="administration" id="administration" /> <label for="administration">administration</label><br /><br />
                                        <br/></td>
                                  </tr>
                                  <tr>
                                      <td width="30">&nbsp;</td>
                                      <td width="240">&nbsp;</td>
                                      <td width="238">&nbsp;</td>
                                  </tr>
								</table>
                                      <div id="etape_fournisseur" style="display:none;">
                                <table width="508" border="0" cellpadding="0" cellspacing="0">
                                      <tr >
                                          <td width="30">&nbsp;</td>
                                          <td width="240"><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Nom de l'entreprise : </strong></label></td>
                                          <td width="331"><input type="text" name="nom_entreprise" id="nom_entreprise" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="240">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                      <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Adresse de l'entreprise : </strong></label></td>
                                          <td width="331"><input type="text" name="adresse_entreprise" id="adresse_entreprise" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="147">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                      <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Code postal l'entreprise : </strong></label></td>
                                          <td width="331"><input type="text" name="code_postal_entreprise" id="code_postal_entreprise" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="147">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                      <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Ville l'entreprise : </strong></label></td>
                                          <td width="331"><input type="text" name="ville_entreprise" id="ville_entreprise" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="147">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                      <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Votre nom : </strong></label></td>
                                          <td width="331"><input type="text" name="nom_contact_entreprise" id="nom_contact_entreprise" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="147">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                      				   <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Votre prénom : </strong></label></td>
                                          <td width="331"><input type="text" name="prenom_contact_entreprise" id="prenom_contact_entreprise" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="147">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                       <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Votre numéro de téléphone : </strong></label></td>
                                          <td width="331"><input type="text" name="telephone_contact_entreprise" id="telephone_contact_entreprise" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="147">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                       <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Votre email : </strong></label></td>
                                          <td width="331"><input type="text" name="email_contact_entreprise" id="email_contact_entreprise" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="147">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                      <tr>
                                        <td>&nbsp;</td>
                                        <td>&nbsp;</td>
                                        <td><input type="submit" value="Envoyer" name="envoi" /><br /></td>                                  
                                      </tr>
                                </table>
                                      </div>
                                      
                                      <div id="etape_administration" style="display:none;">
                                      <table width="508" border="0" cellpadding="0" cellspacing="0">
                                      <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Le nom de l'administration : </strong></label></td>
                                          <td width="331"><input type="text" name="nom_administration" id="nom_administration" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="240">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                      <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Votre nom : </strong></label></td>
                                          <td width="331"><input type="text" name="nom_contact_administration" id="nom_contact_administration" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="240">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                      <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Votre prénom : </strong></label></td>
                                          <td width="331"><input type="text" name="prenom_contact_administration" id="prenom_contact_administration" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="240">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                      <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Votre numéro de téléphone : </strong></label></td>
                                          <td width="331"><input type="text" name="telephone_contact_administration" id="telephone_contact_administration" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="240">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                      <tr >
                                          <td width="30">&nbsp;</td>
                                          <td><label ><span class="FORMULAIRE_ROUGE"><strong>*</strong></span><strong> Votre email : </strong></label></td>
                                          <td width="331"><input type="text" name="email_contact_administration" id="email_contact_administration" value="" size="36" />
                                            <br/></td>
                                      </tr>
                                      <tr>
                                          <td width="30">&nbsp;</td>
                                          <td width="240">&nbsp;</td>
                                          <td width="331">&nbsp;</td>
                                      </tr>
                                      <tr>
                                          <td>&nbsp;</td>
                                          <td>&nbsp;</td>
                                          <td><input type="submit" value="Envoyer" name="envoi" /><br /></td>                                  
                                      </tr>
                                      </table>
                                      </div>
                                      </p>
                            </form>
						</tr>
						<tr>
                            <td width="30">&nbsp;</td>
                            <td width="240">&nbsp;</td>
                            <td width="238">&nbsp;</td>
                        </tr>
                    </table>
				</td>            	
            </tr>
		</table>


Par contre il y a onclick="etapeSuivante(this.id)" dans le input à la ligne 33.
Je le met là sinon je peux pas l'afficher sur le forum.

Merci d'avance en espèrent que j'ai été clair.

4 réponses

Gremy87 Messages postés 360 Statut Membre 38
 
Bonjour,

"Mais le problème qui m'arrive est comment faire pour faire que si c'est cette partie du formulaire ben vérifier cette partie, si c'est l'autre l'autre partie. "

c'est à peu près clair comme du pétrole brut =° lol

donc ce que tu veux c'est tester les variables de la partie du formulaire choisie en fonction des boutons radio? c'est ca?

ben tu test d'abord la valeur des boutons radio et si c'est l'un tu fais tel batterie de test si c'est l autre, tu fais l 'autre batterie de test.

avec quelques if ca suffit pas? ou j ai loupé des trucs?
0
Mopire Messages postés 25 Statut Membre
 
oui avec un if c'est bon mais je doit mettre if (koi==koi) {} else {}

En fait c'est juste qu j'arrive pas avoir a voir sa.
0
Gremy87 Messages postés 360 Statut Membre 38
 
ok,

if($_POST['etape']=="fournisseur")
{
//tests de la partie fournisseur
}
else
{
//test de la partie administration
}

$_POST['etape'] c'est la valeur de tes boutons radio
0
mpmp93 Messages postés 7217 Date d'inscription   Statut Membre Dernière intervention   1 340
 
Bonjour,

Puis-je vous suggérer de ne plus utiliser TABLE pour vos formulaires. Une bonne solution ici:
http://html5.immo-scope.com/index.php?page=html5/formulairesSansTable

Egalement dans votre code source, cette ligne:
<form method="post" action="envoie_inscription.php">


doit se trouver avant TABLE et le FORM après /TABLE....

Sinon, concernant votre solution:
- selon la valeur prise par le bouton radio, vous faites un jeu de test adapté à la valeur du bouton radio. Exemple:

<?php
$etape = $_POST['etape'];

if ($etape=='fournisseur') {
  ..ma première série de tests....
} elseif ($etape=='administration') {
  ..mon autre série de tests....
}


A+
0