Select et message d'erreur

Signaler
Messages postés
53
Date d'inscription
dimanche 25 janvier 2004
Statut
Membre
Dernière intervention
11 juin 2007
-
Messages postés
3426
Date d'inscription
lundi 26 décembre 2005
Statut
Membre
Dernière intervention
14 janvier 2011
-
Bonjour
jai modifie mon formulaire d'enregistrement depuis je n'ai plus d'alert d'erreur pour le pays
je pense que cela viens de textbox que je lai modifie en select, je chercher l'erreur mais je n'ai pas trouver....
j'ai besoin d'aide pour trouver la solution.

merci

<?php
/*
  --


  Author: Marc D.
  Email: [mailto:markus@shopping-cart-software-solution.com markus@shopping-cart-software-solution.com]
  Copyright (c) Copyright France.com 943B168
  Released under custom license as written to http://www.shopping-cart-software-solution.com/license.php | http://www.boutikone.com/accord_boutique_en_ligne.php
*/
$date = date("Y-m-d H:i:s");


if(isset($_POST['actionPro']) AND $_POST['actionPro']=="proOk") {


if(isset($_POST['clientEmailPro']) AND !empty($_POST['clientEmailPro']) AND
isset($_POST['clientGenderPro']) AND !empty($_POST['clientGenderPro']) AND
isset($_POST['clientCompPro']) AND !empty($_POST['clientCompPro']) AND
isset($_POST['clientCityPro']) AND !empty($_POST['clientCityPro']) AND
isset($_POST['clientPostCodePro']) AND !empty($_POST['clientPostCodePro']) AND
isset($_POST['clientPaysPro']) AND !empty($_POST['clientPaysPro']) AND
isset($_POST['clientFactActivitePro']) AND !empty($_POST['clientFactActivitePro']) AND
isset($_POST['clientTelephonePro']) AND !empty($_POST['clientTelephonePro']) AND
isset($_POST['clientTVAPro']) AND !empty($_POST['clientTVAPro']) AND
isset($_POST['clientLastnamePro']) AND !empty($_POST['clientLastnamePro']) AND
isset($_POST['clientFirstnamePro']) AND !empty($_POST['clientFirstnamePro']) AND
isset($_POST['clientPostePro']) AND !empty($_POST['clientPostePro']))
{
// Verification email + tva
$stateCommentPro="";
$statePro1=0;
$queryPro1 = mysql_query("SELECT users_pro_email FROM users_pro WHERE users_pro_email= '".$_POST['clientEmailPro']."' ");
$queryPro1Num = mysql_num_rows($queryPro1);if($queryPro1Num > 0) {$statePro1 1; $stateCommentPro "
Email déjà enregistré !
";} else {$statePro1 =0; $stateCommentPro = "";}


$statePro2=0;
$queryPro2 = mysql_query("SELECT users_pro_tva FROM users_pro WHERE users_pro_tva= '".$_POST['clientTVAPro']."' ");
$queryPro2Num = mysql_num_rows($queryPro2);
if($queryPro2Num > 0) {$statePro2 = 1; $stateCommentPro .= "
Numéro de TVA déjà enregistré !
";} else {$statePro2 =0; $stateCommentPro .= "";}


$resultPro = $statePro1 + $statePro2;
if($resultPro > 0) {
    print $stateCommentPro;
}
else {


// Date
$datePro = date("Y-m-d H:i:s");
// Generation alleatoire du Numero client et du NIC
    $str1 = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789ABCDEFGHIJKLMNPQRSTUVWXYZ123456789';
    $str2 = 'ABCDEFGHIJKLMNPQRSTUVWXYZ123456789ABCDEFGHIJKLMNPQRSTUVWXYZ123456789';
  $proPassword = '';
     for ( $i = 0; $i < 7 ; $i++ ) {
         $proPassword .= substr($str1, rand(0, strlen($str1) - 1), 1);
        }


      mysql_query("INSERT INTO users_pro
                   SET
                   users_pro_email = '".$_POST['clientEmailPro']."',
                   users_pro_gender = '".$_POST['clientGenderPro']."',
                   users_pro_company = '".$_POST['clientCompPro']."',
                   users_pro_address = '".$_POST['clientStreetAddressPro']."',
                   users_pro_city = '".$_POST['clientCityPro']."',
                   users_pro_postcode = '".$_POST['clientPostCodePro']."',
                   users_pro_country = '".$_POST['clientPaysPro']."',
                   users_pro_activity = '".$_POST['clientFactActivitePro']."',
                   users_pro_telephone = '".$_POST['clientTelephonePro']."',
                   users_pro_fax = '".$_POST['clientFaxPro']."',
                   users_pro_tva = '".$_POST['clientTVAPro']."',
                   users_pro_lastname = '".$_POST['clientLastnamePro']."',
                   users_pro_firstname = '".$_POST['clientFirstnamePro']."',
                   users_pro_poste = '".$_POST['clientPostePro']."',
                   users_pro_comment = '".$_POST['clientCommentPro']."',
                   users_pro_password = '".$proPassword."',
                   users_pro_date_added = '".$datePro."'
                   ");


// Avertissement email nouvelle inscription to admin
      $scss = "NOUVELLE INSCRIPTION PRO\r\n";
      $scss .= "Date: ".date("Y-M-d h:m:s")."\r\n";
      $scss .= "ID #:".$proPassword;
     
      $toMe = $mailInfo;
      $subjectMe = "[NOUVELLE INSCRIPTION PRO] - ID #:".$proPassword;
      $fromMe = $mailInfo;
// Send email
      mail($toMe, $subjectMe, $scss,
      "From: $fromMe\r\n"
      ."Reply-To: $fromMe\r\n"
      ."X-Mailer: PHP/" . phpversion());
                  
print "
Vos informations ont été envoyé avec succés!

Aprés vérification vous recevrez un email avec l'accés unique à votre compte.

Merci !

";
}
}
else {
    print "Un ou des champs obligatoire ne sont pas valide.
Recommencez!

";
}
}
?>


 
<script language ="javascript">
function formu() {
<!--
  var error11 = 0;
  var error_message11 = "";


  var clientFirstnamePro = document.form101.clientFirstnamePro.value;
  var clientLastnamePro = document.form101.clientLastnamePro.value;
  var clientEmailPro = document.form101.clientEmailPro.value;
  var clientStreetAddressPro = document.form101.clientStreetAddressPro.value;
  var clientPostCodePro = document.form101.clientPostCodePro.value;
  var clientCityPro = document.form101.clientCityPro.value;
  var clientPaysPro = document.form101.clientPaysPro.value;
  var clientTelephonePro = document.form101.clientTelephonePro.value;
  var clientTVAPro = document.form101.clientTVAPro.value;
  var clientCompPro = document.form101.clientCompPro.value;
  var clientFactActivitePro = document.form101.clientFactActivitePro.value;
  var clientPostePro = document.form101.clientPostePro.value;


  if (document.form101.elements['clientEmailPro'].type != "hidden") {    if (clientEmailPro '' || clientEmailPro.length < 6 || clientEmailPro.indexOf ([mailto:'@' '@']) -1 || clientEmailPro.indexOf ('.') == -1 ) {
      error_message11 = error_message11 + "<?php print CHAMPS_NON_VALIDE;?> '<?php print ADRESSE_EMAIL;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientCompPro'].type != "hidden") {
    if (clientCompPro == '' || clientCompPro.length < 2) {
      error_message11 = error_message11 + "<?php print CHAMPS_NON_VALIDE;?> '<?php print COMPAGNIE2;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientStreetAddressPro'].type != "hidden") {
    if (clientStreetAddressPro == '' || clientStreetAddressPro.length < 5) {
      error_message11 = error_message11 + "<?php print CHAMPS_NON_VALIDE;?> '<?php print ADRESSE;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientCityPro'].type != "hidden") {
    if (clientCityPro == '' || clientCityPro.length < 3) {
      error_message11 = error_message11 + "<?php print CHAMPS_NON_VALIDE;?> '<?php print VILLE;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientPostCodePro'].type != "hidden") {
    if (clientPostCodePro == '' || clientPostCodePro.length < 4) {
      error_message11 = error_message11 + "<?php print CHAMPS_NON_VALIDE;?> '<?php print CODE_POSTAL;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientPaysPro'].type != "hidden") {
    if (clientPaysPro == '') {
      error_message11 = error_message11 + "<?php print CHAMPS_NON_VALIDE;?> '<?php print PAYS;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientFactActivitePro'].type != "hidden") {
    if (clientFactActivitePro == '') {
      error_message11 = error_message11 + "<?php print CHAMPS_NON_VALIDE;?> '<?php print ACTVITE;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientTelephonePro'].type != "hidden") {
    if (clientTelephonePro == '' || clientTelephonePro.length < 6) {
      error_message11 = error_message11 + "<?php print VEUILLEZ_SELECTIONNER;?> 'Telephone'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientTVAPro'].type != "hidden") {
    if (clientTVAPro == '') {
      error_message11 = error_message11 + "<?php print VEUILLEZ_SELECTIONNER;?> '<?php print NO_TVA;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientGenderPro'].type != "hidden") {
    if (document.form101.clientGenderPro[0].checked || document.form101.clientGenderPro[1].checked) {
    } else {
      error_message11 = error_message11 + "<?php print VEUILLEZ_SELECTIONNER;?> '<?php print CIVILITE;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientLastnamePro'].type != "hidden") {
    if (clientLastnamePro == '' || clientLastnamePro.length < 2) {
      error_message11 = error_message11 + "<?php print CHAMPS_NON_VALIDE;?> '<?php print NOM;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientFirstnamePro'].type != "hidden") {
    if (clientFirstnamePro == '' || clientFirstnamePro.length < 2) {
      error_message11 = error_message11 + "<?php print CHAMPS_NON_VALIDE;?> '<?php print PRENOM;?>'.\n";
      error11 = 1;
    }
  }
  if (document.form101.elements['clientPostePro'].type != "hidden") {
    if (clientPostePro == '') {
      error_message11 = error_message11 + "<?php print CHAMPS_NON_VALIDE;?> '<?php print POSTE;?>'.\n";
      error11 = 1;
    }
  }


  if (error11 == 1) {
    alert(error_message11);
    return false;
  } else {
    return true;
  }
}
//-->
</script>


<form action="your_account.php" method="POST" name="form101" onsubmit="return formu()";>


      ----

           
        <table border="0" width="400" cellspacing="0" cellpadding="5" class="TABLE1">
         ----

           , &nbsp;<?php print ADRESSE_EMAIL;?>&nbsp;:</td>
            &nbsp;
             
              &nbsp;&nbsp;*,
         
       


       
<?php
// ----------
// Infos Pros
// ----------
?>
      </td>
    </tr>
    <tr>
    <tr>
      <td>
        <?php print "Coordonnées professionnelles";?> </td>
    </tr>
    <tr>
      <td valign ="top">
                  ----

            &nbsp;<?php print COMPAGNIE2;?>&nbsp;:,
               &nbsp;&nbsp;&nbsp;*
   ,
         
          ----

            &nbsp;<?php print ADRESSE;?>&nbsp;:,
                          &nbsp;<textarea type= "text" name="clientStreetAddressPro" cols="35" rows="1" value=""></textarea>&nbsp;&nbsp;*
   ,
         
          ----

            &nbsp;<?php print VILLE;?>&nbsp;:,
                 &nbsp;&nbsp;&nbsp;*
   ,
         
          ----

            &nbsp;<?php print CODE_POSTAL;?>&nbsp;:,
                 &nbsp;&nbsp;&nbsp;*
   ,
         
           ----

            &nbsp;<?php print PAYS;?>&nbsp;:,
                &nbsp;<?php
  

    $query_select = "SELECT countries_name FROM countries ORDER BY countries_id";
    $req_select = mysql_query($query_select) or die('Erreur SQL !'.$query_select.'
'.mysql_error());
?>
<select name="clientPaysPro">
<option value="" selected></option>
<?php
    
// boucle permetant le listage des valeurs et l'affichage -----------------    
        while($select = mysql_fetch_array($req_select))
        {
        echo '<option value='.$select['countries_name'].'>'.$select['countries_name'].'</option>';
        }

 
        ?>
    </select>&nbsp;&nbsp;*

   ,
         
            ----

            &nbsp;<?php print ACTVITE;?>&nbsp;:,
                 &nbsp;&nbsp;&nbsp;*
   ,
         
       

       
       
      </td>


    </tr>
    <tr>
      <td valign="top">
     
                  ----

            &nbsp;<?php print NUMERO_DE_TELEPHONE;?>&nbsp;:,
            &nbsp;
             
              &nbsp;&nbsp;*
           ,
         
          ----

            &nbsp;<?php print NUMERO_DE_FAX;?>&nbsp;:,
            &nbsp;
             
              &nbsp;,
         
       

       
      </td>
      </tr>
      <tr>
      <td align="top">
        <?php
          if($noTva == "oui") {
        ?>
                 ----

            &nbsp;<?php print NO_TVA." :";?>
           ,
            &nbsp;
              &nbsp;&nbsp;*
           ,
         
       

        <?php
           }
           else {
                print '';
           }
        ?>
      </td>
    </tr>
    <tr>
      <td>

     
        <?php print "Coordonnées personnelle";?> </td>
    </tr>
    <tr>
      <td valign ="top">
<?php
// ------------
// Infos persos
// ------------
?>
                ----

            &nbsp;<?php print CIVILITE;?>&nbsp;:,
            &nbsp;
             
              &nbsp;<?php print M;?>&nbsp;&nbsp;
             
              &nbsp;<?php print MME;?>&nbsp;&nbsp;*,
         
          ----

            &nbsp;<?php print NOM;?>:,
            &nbsp;
              &nbsp;&nbsp;*,
         
          ----

            &nbsp;<?php print PRENOM;?>&nbsp;:,
            &nbsp;
              &nbsp;&nbsp;*,
         
          ----

            &nbsp;<?php print "Poste";?>&nbsp;:,
            &nbsp;
              &nbsp;&nbsp;*,
         
       

</td></tr><tr>
   
   
   
   
      <td>

        <?php print COMMENTAIRES;?></td>
    </tr>
    <tr>
      <td valign="top">
                  ----

                          <textarea name="clientCommentPro" rows="4" cols="50"></textarea>
           ,
         
       

      </td>
    </tr>
  </table>
  ----

    ">,
 
  ----

    * <?php print CHAMPS_OBLIGATOIRES;?>,
 


</form>


 

1 réponse

Messages postés
3426
Date d'inscription
lundi 26 décembre 2005
Statut
Membre
Dernière intervention
14 janvier 2011
16
B

onjour...

Si j'ai bien compris ton pays est récupéré grace à une Select Box
donc il faut utiliser



selectedIndex pour connaitre quelle ligne est sélectionnée


var Pays  ="";




var Index = document.Nom_FORM.Nom_SELECT.selectedIndex;
if( Index > 0) // ce n'est pas la première ligne
  Pays =
document.Nom_FORM.Nom_SELECT

.options[Index].text;
else
  alert( 'Vous devez sélectionner un Pays');











;0)