8721 sujets

Développement web côté serveur, CMS

Bonsoir,

***************************************************************************************************************************
Hello PetiBato et Lothindil si vous passez par là Smiley smile

(J'utilise encore mysql au lieu de mysqli ou pdo parce que Free qui m'héberge pour l'instant ne les supporte pas .... ).

* Je cherche des heures avant de poster, je précise *
****************************************************************************************************************************

Page mon_compte.php, j'ai mon formulaire (1 form à 2 submits) qui est affiché avec les valeurs précédemment renseignées par l'utilisateur lors de son passage sur inscription.php.
Il peut au submit, modifier ses données grâce à un UPDATE en bdd.

Question 1 :
Mon $update_ok = 'Vos modifications ont bien été enregistrées. Merci '; (situé juste après chacun de mes 2 mysql_query("UPDATE")) ne s'affiche pas alors que la modification en base s'est bien déroulée et qu'il a son emplacement de prévu au tout début de mon <div class="enregistrement"> (juste en dessous du menu).


Question 2:
Après avoir updaté ses infos perso, le user redirigé sur "mon_compte_update_ok.php" (à défaut d'avoir son message $update_ok) qui retourne sur la page mon_compte.php a toute une série de warnings du type Notice: Undefined index: pseudo in C:\wamp\www\PivoineMercerie\mon_compte.php on line 270 pour chaque champ de mon form... alors que ces warnings ne s'affichaient pas avant le update... Why ? Il me semble pourtant avoir correctement défini mes variables. Mais apparemment ya un truc qui cloche... et je n'arrive pas à trouver l'origine du problème.


Merci pour vos lumières,
Bonne fin de soirée Smiley smile



<?php session_start();


if (isset($_SESSION['pseudo']) && isset($_SESSION['password']) )  
   {$pseudo=$_SESSION['pseudo']; $password=$_SESSION['password']; 
    $bienvenue_compte = " Bienvenue sur votre compte " .htmlspecialchars($_SESSION['pseudo']) . "! ";
   }   
	 
else if (isset($_COOKIE['pseudo']) && isset($_COOKIE['password']))  
        {$pseudo=$_COOKIE['pseudo']; $password=$_COOKIE['password'];
		  $bienvenue_compte =  " Bienvenue sur votre compte " .htmlspecialchars($_COOKIE['pseudo']). "! ";
	    } 
else {header('Location:stop_connection-requise.php');}

	
	
	if(isset($_COOKIE['pseudo']) || isset($_SESSION['pseudo']) )
	{  
	  include('mysql_connect_pivoine.php');
	
	 $requete=("SELECT * FROM users WHERE pseudo='$pseudo'");
	 $resultat = mysql_query($requete) or die("Query failed" );
	 while ($ligne = mysql_fetch_assoc($resultat)) 
	 {
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/jquery-1.10.2.min.js"> </script>
<script type="text/javascript" src="js/pivoine.js"> </script>
<link rel="stylesheet" href="PivoineMercerie.css" />


<title>Pivoine Mercerie en ligne Marmande </title>
</head>

<body class="body2">


<div class="conteneur_principal_index">
<div class="head"> Pivoine Mercerie </div>

<div id="menu">
  <ul id="onglets">
    <li><a href="index.php"> Accueil </a></li>
    <li><a href="mercerie_boutique_en_ligne.php"> Boutique en ligne </a></li>
    <li><a href="inscription.php"> Créer un compte </a></li>
    <li><a href="connexion.php"> Se connecter </a></li>
    <li class="active"><a href="mon_compte.php"> Mon compte </a></li>
    <li><a href="panier.php"> Mon panier </a></li>
    <li><a href="map.php"> Contact </a></li>
  </ul>
</div>



<div class="enregistrement"> 

<p>
<span class="membre"> <?php if(isset($bienvenue_compte)) echo $bienvenue_compte; ?> </span> <br />
<span class="membre"> <?php if(isset($update_ok)) echo $update_ok; ?> </span>
</p>
<div class="enregistrement_compte"> 
<p class="mon_compte"> Mon compte </p>
<form name="registration_update" id="registration" action="" method="post">



<fieldset id="identifiants_registration">
 <legend > Mes identifiants </legend> 		
 <p >  
    <label for="pseudo" id="label_pseudo"> Pseudo : *</label><br />
    <input type="text" name="pseudo" id="pseudo" class="field" placeholder=" 6 caractères minimum" size="30" maxlength="70" tabindex="10" 
    value="<?php echo $ligne['pseudo']; ?> " /> 

    <br />
    <br />
  						
<script src="jquery.js" type="text/javascript"> </script>
<script src="js/verifpseudo_update.js" type="text/javascript"> </script>



    <label for="password" id="label_pass"> Mot de passe : *</label> <br />
    <input type="password" name="password" id="password_connexion" class="field" placeholder=" 6 caractères minimum" size="30" maxlength="70" tabindex="20" 
    value="<?php echo $ligne['password']; ?>"/>    
    <span class="error_message"> <?php if (isset($erreurpassword)) echo $erreurpassword; ?> </span>
    <br />
    <br />
     
    <label for="password" id="label_pass2"> Retapez votre mot de passe : * </label>   <br /> 
    <input type="password" name="repeatpassword" id="password_connexion" class="field" size="30" maxlength="70" tabindex="30" value="<?php echo $ligne['password']; ?>"/>      
    <span class="error_message"> <?php if (isset($erreurpassword2)) echo $erreurpassword2;  ?> </span>
                                      <br /><br />
  
   <label for="email" id="label_email"> Email : * </label> <br />
    <input type="text" name="email" id="email" class="field" size="30" maxlength="70" tabindex="31"  value="<?php echo $ligne['email']; if (isset($email)) echo $email; ?>" /> 
    <span class="error_message_email">  </span>
    <span class="error_message"> <?php if(isset($erreuremail)) echo $erreuremail;?> </span>
    
	                                    

    <script type="text/javascript" src="js/jquery-1.10.2.min.js" > </script>
    <script src="js/verif_email.js" type="text/javascript"> </script>
<br /><br />
 </p> 
</fieldset> 
   
   
 <fieldset id="coordonnees_registration">
    <legend> Mon adresse de livraison </legend> 		
<p> 
    <label for="civilite"  id="label_civilite" > Civilit&eacute; : * </label><br />
    <select name="civilite" id="civilite" class="field" tabindex="40" /> 
    <option value=" "> <?php echo $ligne['civilite']; ?> </option>
<?php 
    $selected = isset( $civilite ) ? $civilite : "" ;
    $selectedValue = 'selected="selected"';
?>
    <option value="Mlle" <?php if ($selected == "Mlle") echo  $selectedValue ; ?>> Mlle </option>
    <option value="Mme" <?php if ($selected == "Mme") echo  $selectedValue ; ?>> Mme </option>
    <option value="Mr" <?php if ($selected == "Mr") echo  $selectedValue ; ?>> Mr </option> 
    </select>
    <span class="error_message"> <?php if(isset($erreurcivilite)) echo $erreurcivilite ; ?> </span>
    <br /><br />

 
    <label for="nom" id="label_nom"> Nom : * </label><br />
    <input type="text" name="nom" id="nom" class="field" size="30" maxlength="70" tabindex="60" value="<?php echo $ligne['nom']; if (isset($nom)) echo $nom; ?>"/> 
    <span class="error_message"> <?php  if (isset($erreurnom)) echo $erreurnom ; ?> </span>  
    <br />
    <br />
    <label for="prenom" id="label_prenom"> Prénom : *</label> <br />   
    <input type="text" name="prenom" id="prenom" class="field" size="30" maxlength="70" tabindex="70" value="<?php echo $ligne['prenom']; if (isset($prenom)) echo $prenom; ?>"/>
    <span class="error_message"> <?php  if (isset($erreurprenom)) echo $erreurprenom ; ?> </span>    <br /><br />

    <label for="societe" id="label_societe"> Société :</label> <br />   
    <input type="text" name="societe" id="societe" class="field" size="30" maxlength="70" tabindex="75" value="<?php echo $ligne['societe']; if (isset($societe)) echo $societe; ?>"/>
    <span class="error_message"> <?php if (isset($erreursociete)) echo $erreursociete ; ?> </span>    <br /><br /> 
       
    <label for="adresse" id="label_adresse"> Adresse : * </label>  <br />  
    <input type="text" name="adresse" id="adresse" class="field" size="30" maxlength="100" tabindex="80" value="<?php echo $ligne['adresse'];  if (isset($adresse)) echo $adresse; ?>"/> 
    <span class="error_message"> <?php if (isset($erreuradresse)) echo $erreuradresse ; ?> </span>   <br /> <br />
    
    <label for="adresse" id="label_adresse2"> Complément d'adresse : </label>  <br />
    <input type="text" name="adresse2" id="adresse2" class="field" size="30" maxlength="100" tabindex="90" value="<?php echo $ligne['adresse2']; if (isset($adresse2)) echo $adresse2; ?>"/>  <br /><br />
     
    <label for="cp" id="label_cp"> Code postal : * </label>  <br />  
    <input type="text" name="cp" id="cp" class="field" size="20"  maxlength="30" tabindex="100" value="<?php  echo $ligne['cp']; if (isset($cp)) echo $cp ; ?>"/> 
    <span class="error_message"> <?php if (isset($erreurcp)) echo $erreurcp ; ?> </span>   <br /><br /> 
    
    <label for="ville" id="label_ville"> Ville : * </label>  <br />  
    <input type="text" name="ville" id="ville" class="field" size="30" maxlength="100" tabindex="110" value="<?php  echo $ligne['ville']; if (isset($ville)) echo $ville ; ?>" /> 
    <span class="error_message"> <?php if(isset($erreurville)) echo $erreurville ; ?> </span>   <br /><br />
    
    <label for="cpays" id="label_pays"> Pays : * </label>  <br />  
    <input type="text" name="pays" id="pays" class="field" size="30" maxlength="100" tabindex="120" value="<?php  echo $ligne['pays']; if (isset($pays)) echo $pays; ?>" />
    <span class="error_message"> <?php if(isset($erreurpays)) echo $erreurpays; ?> </span>    <br /><br />
   
    <label for="tel" id="label_tel"> Téléphone : *</label> <br />
    <input type="text" name="tel" id="tel" class="field" placeholder=" 10 chiffres sans espace" size="30" maxlength="70" tabindex="140" value="<?php  echo $ligne['tel']; if (isset($tel)) echo $tel; ?>" />   <span class="error_message"> <?php if (isset($erreurtel)) echo $erreurtel;  ?></span>


      <br /><br />
     <input type="checkbox" name="check_livfact" id="check_livfact"   tabindex="160" />
     <label for="livraisonfacturation" id="label_livraisonfacturation"> Utiliser mon adresse de livraison comme adresse de facturation</label>
     <br /><br />
     
     <input type="submit" name="submit_update" id="submit" value="Modifier"  tabindex="150" />
     
 
     <br /><br /><br />
</p>     

  </fieldset> 

<div id="div_coordonnees_facturation">
 <fieldset id="coordonnees_facturation">
    <legend> Mon adresse de facturation - si différente de l'adresse de livraison </legend> 		

<p>
    <label for="civilite_facturation"  id="label_civilite_facturation" > Civilit&eacute; : * </label><br />
    <select name="civilite_facturation" id="civilite_facturation" class="field" tabindex="40" /> 
    <option selected="selected" value=""> <?php echo $ligne['civilite_facturation']; ?></option>
<?php 
    $selected_a = isset( $civilite_facturation ) ? $civilite_facturation : "" ;
    $selectedValue_a = 'selected="selected"';
?>
    <option value="Mlle" <?php if ($selected_a == "Mlle") echo  $selectedValue_a ; ?>> Mlle </option>
    <option value="Mme" <?php if ($selected_a == "Mme") echo  $selectedValue_a ; ?>> Mme </option>
    <option value="Mr" <?php if ($selected_a == "Mr") echo  $selectedValue_a ; ?>> Mr </option> 
    </select>
    <span class="error_message"> <?php if(isset($erreurcivilite)) echo $erreurcivilite; ?> </span>
    <br /><br />
 
    <label for="nom" id="label_nom_facturation"> Nom : * </label><br />
    <input type="text" name="nom_facturation" id="nom" size="30" maxlength="70"  tabindex="180"  
    value="<?php  echo $ligne['nom_facturation']; if(isset($nom_facturation)) echo $nom_facturation; ?>"  />   
    <br />
    <br />
    <label for="prenom" id="label_prenom_facturation"> Prénom : *</label> <br />   
    <input type="text" name="prenom_facturation" id="prenom" size="30" maxlength="70" tabindex="190"
    value="<?php  echo $ligne['prenom_facturation']; if(isset($prenom_facturation)) echo $prenom_facturation; ?>" />    <br /><br />

    <label for="societe" id="label_societe_facturation"> Société :</label> <br />   
    <input type="text" name="societe_facturation" id="societe" size="30" maxlength="70" tabindex="200" 
    value="<?php  echo $ligne['societe_facturation']; if(isset($societe_facturation)) echo $societe_facturation; ?>"/>    <br /><br /> 
       
    <label for="adresse" id="label_adresse_facturation"> Adresse : * </label>  <br />  
    <input type="text" name="adresse_facturation" id="adresse" size="30" maxlength="100" tabindex="210" 
    value="<?php  echo $ligne['adresse_facturation']; if(isset($adresse_facturation)) echo $adresse_facturation; ?>"/>    <br /> <br />
    
    <label for="adresse" id="label_adresse2_facturation"> Complément d'adresse : </label>  <br />
    <input type="text" name="adresse2_facturation" id="adresse2" size="30" maxlength="100" tabindex="220" 
     value="<?php  echo $ligne['adresse2_facturation']; if(isset($adresse2_facturation)) echo $adresse2_facturation; ?>"/>  <br /><br />
     
    <label for="cp" id="label_cp_facturation"> Code postal : * </label>  <br />  
    <input type="text" name="cp_facturation" id="cp" size="20" maxlength="30" tabindex="230" 
     value="<?php  echo $ligne['cp_facturation']; if(isset($cp_facturation)) echo $cp_facturation; ?>"/>    <br /><br /> 
    
    <label for="ville" id="label_ville_facturation"> Ville : * </label>  <br />  
    <input type="text" name="ville_facturation" id="ville" size="30" maxlength="100" tabindex="240" 
     value="<?php  echo $ligne['ville_facturation']; if(isset($ville_facturation)) echo $ville_facturation; ?>"/>    <br /><br />
    
    <label for="cpays" id="label_pays_facturation"> Pays : * </label>  <br />  
    <input type="text" name="pays_facturation" id="pays" size="30" maxlength="100" tabindex="250" 
     value="<?php  echo $ligne['pays_facturation']; if(isset($pays_facturation)) echo $pays_facturation; ?>"/>    <br /><br />
    
    
     <label for="email" id="label_email_facturation"> Email : * </label> <br />   
    <input type="text" name="email_facturation" id="email_facturation" size="30" maxlength="70" tabindex="260"
     value="<?php  echo $ligne['email_facturation']; if(isset($email_facturation)) echo $email_facturation; ?>" />    <br /><br />
    
    <label for="tel" id="label_tel_facturation"> Téléphone : *</label><br />    
    <input type="text" name="tel_facturation" id="tel" placeholder=" 10 chiffres sans espace" size="30" maxlength="70" tabindex="270" 
     value="<?php  echo $ligne['tel_facturation']; if(isset($tel_facturation)) echo $tel_facturation; ?>"/>   

<?php 
}
 
// $resultat->Close(); // Termine le traitement de la requête
 
}else {header('Location:stop_connection-requise.php');} ?>
 </p>
      <br /><br />
    <input type="submit" name="submit2_update" id="submit2" value="Modifier"   tabindex="280" />


  </fieldset> 
</div>
</form>
</div>

 
</div>

</div>




<div class="adresse"> <span class="pivoine_adresse"> Pivoine Mercerie</span><br /> 
8, Rue des Marcassins<br />
 47200 Marmande</div>

<?php 
if(isset($_POST['submit_update']) && !empty($_POST['submit_update']) ) 
   $valid = true;   
   $pseudo=htmlspecialchars(trim($_POST["pseudo"])); 
   $password=htmlspecialchars(trim($_POST["password"])); 
   $password=md5($password); 
   $repeatpassword=htmlspecialchars(trim($_POST["repeatpassword"])); 
   $email=htmlspecialchars(trim($_POST["email"]));
   $civilite=htmlspecialchars(trim($_POST["civilite"])); 
   $nom=htmlspecialchars(trim($_POST["nom"])); 
   $prenom=htmlspecialchars(trim($_POST["prenom"])); 
   $societe=htmlspecialchars(trim($_POST["societe"])); 
   $adresse=htmlspecialchars(trim($_POST["adresse"])); 
   $adresse2=htmlspecialchars(trim($_POST["adresse2"])); 
   $cp=htmlspecialchars(trim($_POST["cp"])); 
   $ville=htmlspecialchars(trim($_POST["ville"]));   
   $pays=htmlspecialchars(trim($_POST["pays"]));        
   $tel=htmlspecialchars(trim($_POST["tel"]));       
   

	if ( empty($_POST['password']))
	   {$valid=false;
		$erreurpassword = "Mot de passe requis";
	   }
	
	if ( strlen($_POST['password']) <6 )
	   {$valid=false;
		$erreurpassword = "6 caractères minimum";
	   }
	   
	if ( empty($_POST['repeatpassword']))
	   {$valid=false;
		$erreurpassword2 = "Répétez votre mot de passe";
	   }
	
	if ($_POST['repeatpassword'] != $_POST['repeatpassword'])
	   {$valid=false;
		$erreurpassword2 = "Les mots de passe doivent être identiques";
	   }else{$password=md5($password);}
	   
	   
 
	   
	if ( empty($_POST['civilite']))
	   {$valid=false;
		$erreurcivilite = "Veuillez indiquer votre civilité";
	   }
	
	if ( empty($_POST['nom']))
	   {$valid=false;
		$erreurnom = "Veuillez indiquer votre nom";
	   }
	
	if ( empty($_POST['prenom']))
	   {$valid=false;
		$erreurprenom =  "Veuillez indiquer votre prénom";
	   }
	   
	if ( empty($_POST['adresse']))
	   {$valid=false;
		$erreuradresse = "Veuillez indiquer votre adresse";
	   }
	   
	if ( empty($_POST['cp']))
	   {$valid=false;
		$erreurcp = "Veuillez indiquer votre code postal";
	   }
	      
    if ( empty($_POST['ville']))
       {$valid = false;
        $erreurville = "Veuillez indiquer votre ville";
       }

	if ( empty($_POST['pays']))
	   {$valid=false;
		$erreurpays = "Veuillez indiquer votre pays";
	   }
	   
	if ( empty($_POST['tel']))
       {$valid=false;
        $erreurtel = "Veuillez indiquer votre numéro de téléphone";
       }
	if (!preg_match(" '([-. ]?[0-9]{2}){4}' ", $_POST['tel']))   
	   {$valid=false;
	    $erreurtel = " 10 chiffres requis";
	   }  
	   


    if (isset($valid))
	   
	   { include('mysql_connect_pivoine.php');
	           $pseudo=mysql_real_escape_string($_POST["pseudo"]); 
			   $password=mysql_real_escape_string($_POST["password"]); 
			   $password=md5($password); 
			   $repeatpassword=mysql_real_escape_string($_POST["repeatpassword"]); 
			   $email=mysql_real_escape_string($_POST["email"]);
			   $civilite=mysql_real_escape_string($_POST["civilite"]); 
			   $nom=mysql_real_escape_string($_POST["nom"]); 
			   $prenom=mysql_real_escape_string($_POST["prenom"]); 
			   $societe=mysql_real_escape_string($_POST["societe"]); 
			   $adresse=mysql_real_escape_string($_POST["adresse"]); 
			   $adresse2=mysql_real_escape_string($_POST["adresse2"]); 
			   $cp=mysql_real_escape_string($_POST["cp"]); 
			   $ville=mysql_real_escape_string($_POST["ville"]);   
			   $pays=mysql_real_escape_string($_POST["pays"]);        
			   $tel=mysql_real_escape_string($_POST["tel"]);      
	    
		 mysql_query("UPDATE users SET  pseudo='$pseudo', password='$password', email='$email', civilite='$civilite', nom='$nom', prenom='$prenom',  
		          societe='$societe', adresse='$adresse', adresse2='$adresse2', cp='$cp', ville='$ville', pays='$pays',  tel='$tel'  
				  WHERE pseudo='$pseudo'  ") 
		 or die(mysql_error() );
		  mysql_close($mysql_connect_pivoine);
		 // header('Location:mon_compte_update_ok.php');
		  $update_ok = 'Vos modifications ont bien été enregistrées. Merci ';
		} 
        

   
/**************************************************** form SUBMIT2_update FACTURATION DIFFERENTE  ******************************************************************/
elseif(isset($_POST['submit2_update']) && !empty($_POST['submit2_update'])) 
{

   $valid = true;
    $pseudo=htmlspecialchars(trim($_POST["pseudo"])); 
	   $password=htmlspecialchars(trim($_POST["password"])); 
	   $password=md5($password); 
	   $repeatpassword=htmlspecialchars(trim($_POST["repeatpassword"])); 
	   $email=htmlspecialchars(trim($_POST["email"]));
	   $civilite=htmlspecialchars(trim($_POST["civilite"])); 
	   $nom=htmlspecialchars(trim($_POST["nom"])); 
	   $prenom=htmlspecialchars(trim($_POST["prenom"])); 
	   $societe=htmlspecialchars(trim($_POST["societe"])); 
	   $adresse=htmlspecialchars(trim($_POST["adresse"])); 
	   $adresse2=htmlspecialchars(trim($_POST["adresse2"])); 
	   $cp=htmlspecialchars(trim($_POST["cp"])); 
	   $ville=htmlspecialchars(trim($_POST["ville"]));   
	   $pays=htmlspecialchars(trim($_POST["pays"]));        
	   $tel=htmlspecialchars(trim($_POST["tel"]));  
 	   
       $civilite_facturation=htmlspecialchars(trim($_POST["civilite_facturation"])); 
	   $nom_facturation=htmlspecialchars(trim($_POST["nom_facturation"])); 
	   $prenom_facturation=htmlspecialchars(trim($_POST["prenom_facturation"])); 
	   $societe_facturation=htmlspecialchars(trim($_POST["societe_facturation"])); 
	   $adresse_facturation=htmlspecialchars(trim($_POST["adresse_facturation"])); 
	   $adresse2_facturation=htmlspecialchars(trim($_POST["adresse2_facturation"])); 
	   $cp_facturation=htmlspecialchars(trim($_POST["cp_facturation"])); 
	   $ville_facturation=htmlspecialchars(trim($_POST["ville_facturation"]));   
	   $pays_facturation=htmlspecialchars(trim($_POST["pays_facturation"]));   
	   $email_facturation=htmlspecialchars(trim($_POST["email_facturation"]));   
	   $tel_facturation=htmlspecialchars(trim($_POST["tel_facturation"]));  

 
	if (empty($_POST['password']))
	   {$valid=false;
		$erreurpassword = "Mot de passe requis";
	   }
	
	if ( strlen($_POST['password']) <6 )
	   {$valid=false;
		$erreurpassword = "6 caractères minimum";
	   }
	   
	if ( empty($_POST['repeatpassword']))
	   {$valid=false;
		$erreurpassword2 = "Répétez votre mot de passe";
	   }
	
	if ($_POST['repeatpassword'] != $_POST['repeatpassword'])
	   {$valid=false;
		$erreurpassword2 = "Les mots de passe doivent être identiques";
	   }else{$password=md5($password);}
	   
	   
	if (! preg_match( "#[a-z0-9._-]+@[a-z0-9._-][^@]+\.[a-z]{2,3}#", $_POST['email']))  /* '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#'*/
	   {$valid=false;
	   $erreuremail = "Votre adresse e-mail n'est pas valide";
	   }
	   
	if ( empty($_POST['civilite']))
	   {$valid=false;
		$erreurcivilite = "Veuillez indiquer votre civilité";
	   }
	
	if ( empty($_POST['nom']))
	   {$valid=false;
		$erreurnom = "Veuillez indiquer votre nom";
	   }
	
	if ( empty($_POST['prenom']))
	   {$valid=false;
		$erreurprenom =  "Veuillez indiquer votre prénom";
	   }
	   
	if ( empty($_POST['adresse']))
	   {$valid=false;
		$erreuradresse = "Veuillez indiquer votre adresse";
	   }
	   
	if ( empty($_POST['cp']))
	   {$valid=false;
		$erreurcp = "Veuillez indiquer votre code postal";
	   }
	      
    if ( empty($_POST['ville']))
       {$valid = false;
        $erreurville = "Veuillez indiquer votre ville";
       }

	if ( empty($_POST['pays']))
	   {$valid=false;
		$erreurpays = "Veuillez indiquer votre pays";
	   }
	      
	if ( empty($_POST['tel']))
       {$valid=false;
        $erreurtel = "Veuillez indiquer votre numéro de téléphone";
       }
	if (!preg_match(" '([-. ]?[0-9]{2}){4}' ", $_POST['tel']))   
	   {$valid=false;
	    $erreurtel = " 10 chiffres";
	   }  
	   
	   
if ( empty($_POST['civilite_facturation']))
	   {$valid=false;
		$erreurcivilite_facturation = "Champ à renseigner";        
	   }
	
	if ( empty($_POST['nom_facturation']))
	   {$valid=false;
		$erreurnom_facturation = "Champ à renseigner";
	   }
	
	if ( empty($_POST['prenom_facturation']))
	   {$valid=false;
		$erreurprenom_facturation =  "Champ à renseigner";
	   }
	   
	if ( empty($_POST['adresse_facturation']))
	   {$valid=false;
		$erreuradresse_facturation = "Champ à renseigner";
	   }
	   
	if ( empty($_POST['cp_facturation']))
	   {$valid=false;
		$erreurcp_facturation = "Champ à renseigner";
	   }
	      
    if (  empty($_POST['ville_facturation']))
       {$valid = false;
        $erreurville_facturation = "Champ à renseigner";
       }

	if ( empty($_POST['pays_facturation']))
	   {$valid=false;
		$erreurpays_facturation = "Champ à renseigner";
	   }
	   
    if ( empty($_POST['email_facturation']))
       {$valid=false;
        $erreuremail_facturation = "Champ à renseigner";
       }
	   
	if (! preg_match( "#[a-z0-9._-]+@[a-z0-9._-][^@]+\.[a-z]{2,3}#", $_POST['email_facturation']))  /* '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#'*/
	   {$valid=false;
	   $erreuremail_facturation = "Cette adresse e-mail n'est pas valide";
	   }
	   
	if (empty($_POST['tel_facturation']))
       {$valid=false;
        $erreurtel_facturation = "Veuillez indiquer votre numéro de téléphone";
       }
	if (!preg_match(" '([-. ]?[0-9]{2}){4}' ", $_POST['tel_facturation']))   
	   {$valid=false;
	    $erreurtel_facturation = " 10 chiffres";
	   }  

    if (isset($valid))
	   { include('mysql_connect_pivoine.php');	
	      $pseudo=mysql_real_escape_string($_POST["pseudo"]); 
		   $password=mysql_real_escape_string($_POST["password"]);
		   $password=md5($password); 
		   $repeatpassword=mysql_real_escape_string($_POST["repeatpassword"]); 
		   $email=mysql_real_escape_string($_POST["email"]);
		   $civilite=mysql_real_escape_string($_POST["civilite"]); 
		   $nom=mysql_real_escape_string($_POST["nom"]); 
		   $prenom=mysql_real_escape_string($_POST["prenom"]); 
		   $societe=mysql_real_escape_string($_POST["societe"]); 
		   $adresse=mysql_real_escape_string($_POST["adresse"]); 
		   $adresse2=mysql_real_escape_string($_POST["adresse2"]); 
		   $cp=mysql_real_escape_string($_POST["cp"]); 
		   $ville=mysql_real_escape_string($_POST["ville"]);   
		   $pays=mysql_real_escape_string($_POST["pays"]);        
		   $tel=mysql_real_escape_string($_POST["tel"]);      
		
		   $civilite_facturation=mysql_real_escape_string($_POST["civilite_facturation"]); 
		   $nom_facturation=mysql_real_escape_string($_POST["nom_facturation"]); 
		   $prenom_facturation=mysql_real_escape_string($_POST["prenom_facturation"]); 
		   $societe_facturation=mysql_real_escape_string($_POST["societe_facturation"]); 
		   $adresse_facturation=mysql_real_escape_string($_POST["adresse_facturation"]); 
		   $adresse2_facturation=mysql_real_escape_string($_POST["adresse2_facturation"]); 
		   $cp_facturation=mysql_real_escape_string($_POST["cp_facturation"]); 
		   $ville_facturation=mysql_real_escape_string($_POST["ville_facturation"]);   
		   $pays_facturation=mysql_real_escape_string($_POST["pays_facturation"]);   
		   $email_facturation=mysql_real_escape_string($_POST["email_facturation"]);   
		   $tel_facturation=mysql_real_escape_string($_POST["tel_facturation"]);  
	
		 mysql_query("UPDATE users SET  pseudo='$pseudo', password='$password', email='$email', civilite='$civilite', nom='$nom', prenom='$prenom',  
		          societe='$societe', adresse='$adresse', adresse2='$adresse2', cp='$cp', ville='$ville', pays='$pays',  tel='$tel',  
				  civilite_facturation='$civilite_facturation', nom_facturation='$nom_facturation', prenom_facturation='$prenom_facturation', 
				  societe_facturation='$societe_facturation', adresse_facturation='$adresse_facturation', adresse2_facturation='$adresse2_facturation', 
				  cp_facturation='$cp_facturation', ville_facturation='$ville_facturation', pays_facturation='$pays_facturation',  
				  email_facturation='$email_facturation', tel_facturation='$tel_facturation' 
		          WHERE pseudo='$pseudo'  ") 
		 or die(mysql_error() );
		  mysql_close($mysql_connect_pivoine);
		 header('Location:mon_compte_update_ok.php');
		 //$update_ok = 'Vos modifications ont bien été enregistrées. Merci ';
		} 
        
	   	 
		
		
		
 }  

else {$valid =false; } 
?>
       



</div>
</body>
</html>


Modifié par Vape6 (30 Sep 2013 - 21:44)
Question 1:
Il est clair qu'au moment où le script passe par là :
<span class="membre"> <?php if(isset($update_ok)) echo $update_ok; ?> </span>

la variable $update_ok n'a pas de valeur, puisque tu la positionnes plus tard. Et si le script se redirige vers lui-même, de toute façon ça redémarre "à zéro" et la variable $update_ok n'a toujours pas de valeur. Si tu veux faire passer des infos de script à script, puisque tu ouvres une session, autant en profiter.
Question 2:
if(isset($_POST['submit_update']) && !empty($_POST['submit_update']) ) 
   $valid = true;   
   $pseudo=htmlspecialchars(trim($_POST["pseudo"])); 

Sur le coup je me demandais pourquoi $_POST['submit_update'] était défini mais pas $_POST["pseudo"], et badaboum, j'ai trouvé : il manque l'accolade du if !!!!

Voilà, sinon, un formulaire à 2 submit, c'est plutôt pas génial, et ton script tient un peu de l'usine à gaz, un peu de modularité ne nuirait pas ! Bon courage Smiley cligne
Bien vu pour l'accolade. Merci. Tu m'as enlevé une belle épine... (la fatigue...)..
* Ok pour mon <span class> $update_ok </span>positionné trop tôt on va dire. Je reste sur mon header('Location:mon_compte_update_ok.php'); qui fait le boulot.
* Ok pour le form à 2 submits ! Oui je vois l'usine à gaz que j'ai créé !!! Smiley biggrin J'ai bien compris...

J'ai gardé une question sous le coude (ne pas trop dévoiler un coup Smiley lol )
Lorsque j'update ma base grâce à mon form, je ne peux plus me connecter ensuite: login ou password incorrect.


Merci, tu m'aides beaucoup.
Buenas noches
Modifié par Vape6 (29 Sep 2013 - 17:21)
Hola, buenas tardes a todos !

Bon je n'avance pas avec mon problème : Lorsque j'update un champ de mon form, il s'enregistre bien en base mais après déconnexion, je ne peux plus me connecter avec mes identifiants (sur login.php).
Un super regard d'expert me sauvera-t-il de cette aliénation?
Merciiiiiiiii d'avance


CONNEXION.PHP


<?php 
session_start();

include('mysql_connect_pivoine.php');
	
if (  (isset($_SESSION['pseudo']) && isset($_SESSION['password']) && isset($_SESSION['id']) )
       || (isset($_COOKIE['pseudo']) && isset($_COOKIE['password']) && isset($_COOKIE['id']) )
   )       
   {  header('Location:is_logged.php');   }
      
else if( isset($_POST['submit_connexion']) && !empty($_POST['pseudo']) && !empty($_POST['password']))  
     { extract($_POST);  // je vous renvoie à la doc de cette fonction
     $password = md5($password); 
	 $password=mysql_real_escape_string($password);
	 $pseudo=mysql_real_escape_string($pseudo);
    
     $query =( "SELECT * FROM users WHERE pseudo='$pseudo' AND password='$password' ");
     $answer = mysql_query($query) or die('Erreur SQL  ');
	
	 $rows=mysql_num_rows($answer);
	  
	   if ($rows > 0) 
	      {	$data = mysql_fetch_assoc($answer);
			   if ($password == $data['password'] && isset($_POST['remember_me'])) 
	         		  { $_COOKIE['pseudo'] = $data['pseudo']; 
		          		$_COOKIE['password'] = $data['password']; 
					$_COOKIE['id'] = $data['id']; 
				setcookie ('pseudo', $pseudo, time()+3600*24*360, '/', null, false, true);
				setcookie ('password', $password, time()+3600*24*360, '/', null, false, true);
				setcookie ('id', $id, time()+3600*24*360, '/', null, false, true);
											
				header('Location:is_logged.php');  // 
			  } 
			   else if ($password == $data['password'] )
			   {
			   $_SESSION['pseudo'] = $data['pseudo']; 
			   $_SESSION['password'] = $data['password'];  
			   $_SESSION['id'] = $data['id'];  
			   header('Location:is_logged.php');  
			  } 
	   else {
			 $erreur_connexion = ' Login et/ou mot de passe incorrect(s) ' ;
									} 
} else { $erreur_connexion = ' Login et/ou mot de passe incorrect(s) ' ;} }

else {echo '';}

  ?>
  
  
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="PivoineMercerie.css" />
<title>Pivoine Mercerie en ligne Marmande </title>
</head>

<body> 
<div class="conteneur_principal_index">

<div class="head"> Pivoine Mercerie </div>

<div id="menu">
  <ul id="onglets">
    <li><a href="index.php"> Accueil </a></li>
    <li><a href="mercerie_boutique_en_ligne.php"> Boutique en ligne </a></li>
    <li><a href="inscription.php"> Créer un compte </a></li>
    <li  class="active"><a href="connexion.php"> Se connecter </a></li>
    <li><a href="mon_compte.php"> Mon compte </a></li>
    <li><a href="panier.php"> Mon panier </a></li>
    <li><a href="map.php"> Contact </a></li>
  </ul>
</div>



<div class="content"> 
<div id="formulaire_connexion">
<p class="connexion"> Connexion </p>
<form action="connexion.php" method="post">
<label for="pseudo" id="label_pseudo"> Pseudo :</label><br />
<input type="text" name="pseudo" id="pseudo_connexion" />   
<br />
<br />
<label for="password" id="label_password"> Mot de Passe :</label><br />
<input type="password" name="password" id="password_connexion" />    <br /><br />


<input type="checkbox" name="remember_me" id="remember_me" />
<label for="remember_me" id="label_remember_me"> Se souvenir de moi </label><br /><br />

<input type="submit" name="submit_connexion" id="submit_connexion" value="Se connecter"  />
</p></form>
</div>

<div id="div_message_connexion"> <span class="error_message_2"> <?php if (isset($erreur_connexion)) echo $erreur_connexion ;  ?> </span> </div>
</div>

<div class="adresse"> <span class="pivoine_adresse"> Pivoine Mercerie</span><br /> 
8, Rue des Marcassins<br />
 47200 Marmande</div>

</div>

</body>
</html>




USINE_a_GAZ.php Aka MON_COMPTE.PHP


<?php session_start();
 

if ( isset($_SESSION['pseudo']) && isset($_SESSION['password']) && isset($_SESSION['id'])  )  
   {$pseudo=$_SESSION['pseudo']; $password=$_SESSION['password'];
   $bienvenue_compte = " Bienvenue sur votre compte " .htmlspecialchars($_SESSION['pseudo']) . "! " ;
   
   }   
	 
else if ( isset($_COOKIE['pseudo']) && isset($_COOKIE['password']) && isset($_COOKIE['id']) ) 
        {$pseudo=$_COOKIE['pseudo']; $password=$_COOKIE['password'];  
		  $bienvenue_compte =  " Bienvenue sur votre compte " .htmlspecialchars($_COOKIE['pseudo']). "! ";
	    } 
else {header('Location:stop_connection-requise.php');}

	
	
	if(isset($_COOKIE['pseudo']) &&  isset($_COOKIE['password']) && isset($_COOKIE['id']) || isset($_SESSION['pseudo']) && isset($_SESSION['password']) && isset($_SESSION['id'])  )
	{  
	  include('mysql_connect_pivoine.php');
	
	 $requete=("SELECT * FROM users WHERE id='".$_SESSION['id']."'  ");
	 $resultat = mysql_query($requete) or die("Query failed" );
	 while ($ligne = mysql_fetch_assoc($resultat)) 
	 {
 
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/jquery-1.10.2.min.js"> </script>
<script type="text/javascript" src="js/pivoine.js"> </script>
<link rel="stylesheet" href="PivoineMercerie.css" />


<title>Pivoine Mercerie en ligne Marmande </title>
</head>

<body class="body2">


<div class="conteneur_principal_index">
<div class="head"> Pivoine Mercerie </div>

<div id="menu">
  <ul id="onglets">
    <li><a href="index.php"> Accueil </a></li>
    <li><a href="mercerie_boutique_en_ligne.php"> Boutique en ligne </a></li>
    <li><a href="inscription.php"> Créer un compte </a></li>
    <li><a href="connexion.php"> Se connecter </a></li>
    <li class="active"><a href="mon_compte.php"> Mon compte </a></li>
    <li><a href="panier.php"> Mon panier </a></li>
    <li><a href="map.php"> Contact </a></li>
  </ul>
</div>



<div class="enregistrement"> 

<p>
<span class="membre"> <?php if(isset($bienvenue_compte)) echo $bienvenue_compte; ?> </span> <br />
</p>
<div class="enregistrement_compte"> 
<p class="mon_compte"> Mon compte </p>
<form name="registration_update" id="registration" action="" method="post">



<fieldset id="identifiants_registration">
 <legend > Mes identifiants </legend> 		
 <p >  
    <label for="pseudo" id="label_pseudo"> Pseudo : *</label><br />
    <input type="text" name="pseudo" id="pseudo" class="field" placeholder=" 6 caractères minimum" size="30" maxlength="70" tabindex="10" 
    value="<?php echo $ligne['pseudo']; ?> " /> 

    <br />
    <br />
  						

<!-- <script src="js/verifpseudo_update.js" type="text/javascript"> </script> -->



    <label for="password" id="label_pass"> Mot de passe : *</label> <br />
    <input type="password" name="password" id="password_connexion" class="field" placeholder=" 6 caractères minimum" size="30" maxlength="70" tabindex="20" 
    value="<?php echo $ligne['password']; ?>"/>    
    <span class="error_message"> <?php if (isset($erreurpassword)) echo $erreurpassword; ?> </span>
    <br />
    <br />
     
    <label for="password" id="label_pass2"> Retapez votre mot de passe : * </label>   <br /> 
    <input type="password" name="repeatpassword" id="password_connexion" class="field" size="30" maxlength="70" tabindex="30" value="<?php echo $ligne['password']; ?>"/>      
    <span class="error_message"> <?php if (isset($erreurpassword2)) echo $erreurpassword2;  ?> </span>
                                      <br /><br />
  
   <label for="email" id="label_email"> Email : * </label> <br />
    <input type="text" name="email" id="email" class="field" size="30" maxlength="70" tabindex="31"  value="<?php echo $ligne['email']; if (isset($email)) echo $email; ?>" /> 
    <span class="error_message_email">  </span>
    <span class="error_message"> <?php if(isset($erreuremail)) echo $erreuremail;?> </span>
    
	                                    

  <!--  <script type="text/javascript" src="js/jquery-1.10.2.min.js" > </script>
    <script src="js/verif_email.js" type="text/javascript"> </script> -->
<br /><br />
 </p> 
</fieldset> 
   
   
 <fieldset id="coordonnees_registration">
    <legend> Mon adresse de livraison </legend> 		
<p> 
    <label for="civilite"  id="label_civilite" > Civilit&eacute; : * </label><br />
    <select name="civilite" id="civilite" class="field" tabindex="40" /> 
    <option value=" "> <?php echo $ligne['civilite']; ?> </option>
<?php 
    $selected = isset( $civilite ) ? $civilite : "" ;
    $selectedValue = 'selected="selected"';
?>
    <option value="Mlle" <?php if ($selected == "Mlle") echo  $selectedValue ; ?>> Mlle </option>
    <option value="Mme" <?php if ($selected == "Mme") echo  $selectedValue ; ?>> Mme </option>
    <option value="Mr" <?php if ($selected == "Mr") echo  $selectedValue ; ?>> Mr </option> 
    </select>
    <span class="error_message"> <?php if(isset($erreurcivilite)) echo $erreurcivilite ; ?> </span>
    <br /><br />

 
    <label for="nom" id="label_nom"> Nom : * </label><br />
    <input type="text" name="nom" id="nom" class="field" size="30" maxlength="70" tabindex="60" value="<?php echo $ligne['nom']; if (isset($nom)) echo $nom; ?>"/> 
    <span class="error_message"> <?php  if (isset($erreurnom)) echo $erreurnom ; ?> </span>  
    <br />
    <br />
    <label for="prenom" id="label_prenom"> Prénom : *</label> <br />   
    <input type="text" name="prenom" id="prenom" class="field" size="30" maxlength="70" tabindex="70" value="<?php echo $ligne['prenom']; if (isset($prenom)) echo $prenom; ?>"/>
    <span class="error_message"> <?php  if (isset($erreurprenom)) echo $erreurprenom ; ?> </span>    <br /><br />

    <label for="societe" id="label_societe"> Société :</label> <br />   
    <input type="text" name="societe" id="societe" class="field" size="30" maxlength="70" tabindex="75" value="<?php echo $ligne['societe']; if (isset($societe)) echo $societe; ?>"/>
    <span class="error_message"> <?php if (isset($erreursociete)) echo $erreursociete ; ?> </span>    <br /><br /> 
       
    <label for="adresse" id="label_adresse"> Adresse : * </label>  <br />  
    <input type="text" name="adresse" id="adresse" class="field" size="30" maxlength="100" tabindex="80" value="<?php echo $ligne['adresse'];  if (isset($adresse)) echo $adresse; ?>"/> 
    <span class="error_message"> <?php if (isset($erreuradresse)) echo $erreuradresse ; ?> </span>   <br /> <br />
    
    <label for="adresse" id="label_adresse2"> Complément d'adresse : </label>  <br />
    <input type="text" name="adresse2" id="adresse2" class="field" size="30" maxlength="100" tabindex="90" value="<?php echo $ligne['adresse2']; if (isset($adresse2)) echo $adresse2; ?>"/>  <br /><br />
     
    <label for="cp" id="label_cp"> Code postal : * </label>  <br />  
    <input type="text" name="cp" id="cp" class="field" size="20"  maxlength="30" tabindex="100" value="<?php  echo $ligne['cp']; if (isset($cp)) echo $cp ; ?>"/> 
    <span class="error_message"> <?php if (isset($erreurcp)) echo $erreurcp ; ?> </span>   <br /><br /> 
    
    <label for="ville" id="label_ville"> Ville : * </label>  <br />  
    <input type="text" name="ville" id="ville" class="field" size="30" maxlength="100" tabindex="110" value="<?php  echo $ligne['ville']; if (isset($ville)) echo $ville ; ?>" /> 
    <span class="error_message"> <?php if(isset($erreurville)) echo $erreurville ; ?> </span>   <br /><br />
    
    <label for="cpays" id="label_pays"> Pays : * </label>  <br />  
    <input type="text" name="pays" id="pays" class="field" size="30" maxlength="100" tabindex="120" value="<?php  echo $ligne['pays']; if (isset($pays)) echo $pays; ?>" />
    <span class="error_message"> <?php if(isset($erreurpays)) echo $erreurpays; ?> </span>    <br /><br />
   
    <label for="tel" id="label_tel"> Téléphone : *</label> <br />
    <input type="text" name="tel" id="tel" class="field" placeholder=" 10 chiffres sans espace" size="30" maxlength="70" tabindex="140" value="<?php  echo $ligne['tel']; if (isset($tel)) echo $tel; ?>" />   <span class="error_message"> <?php if (isset($erreurtel)) echo $erreurtel;  ?></span>


      <br /><br />
     <input type="checkbox" name="check_livfact" id="check_livfact"   tabindex="160" />
     <label for="livraisonfacturation" id="label_livraisonfacturation"> Utiliser mon adresse de livraison comme adresse de facturation</label>
     <br /><br />
     
     <input type="submit" name="submit_update" id="submit" value="Modifier"  tabindex="150" />
     
 
     <br /><br /><br />
</p>     

  </fieldset> 

<div id="div_coordonnees_facturation">
 <fieldset id="coordonnees_facturation">
    <legend> Mon adresse de facturation - si différente de l'adresse de livraison </legend> 		

<p>
    <label for="civilite_facturation"  id="label_civilite_facturation" > Civilit&eacute; : * </label><br />
    <select name="civilite_facturation" id="civilite_facturation" class="field" tabindex="40" /> 
    <option selected="selected" value=""> <?php echo $ligne['civilite_facturation']; ?></option>
<?php 
    $selected_a = isset( $civilite_facturation ) ? $civilite_facturation : "" ;
    $selectedValue_a = 'selected="selected"';
?>
    <option value="Mlle" <?php if ($selected_a == "Mlle") echo  $selectedValue_a ; ?>> Mlle </option>
    <option value="Mme" <?php if ($selected_a == "Mme") echo  $selectedValue_a ; ?>> Mme </option>
    <option value="Mr" <?php if ($selected_a == "Mr") echo  $selectedValue_a ; ?>> Mr </option> 
    </select>
    <span class="error_message"> <?php if(isset($erreurcivilite)) echo $erreurcivilite; ?> </span>
    <br /><br />
 
    <label for="nom" id="label_nom_facturation"> Nom : * </label><br />
    <input type="text" name="nom_facturation" id="nom" size="30" maxlength="70"  tabindex="180"  
    value="<?php  echo $ligne['nom_facturation']; if(isset($nom_facturation)) echo $nom_facturation; ?>"  />   
    <br />
    <br />
    <label for="prenom" id="label_prenom_facturation"> Prénom : *</label> <br />   
    <input type="text" name="prenom_facturation" id="prenom" size="30" maxlength="70" tabindex="190"
    value="<?php  echo $ligne['prenom_facturation']; if(isset($prenom_facturation)) echo $prenom_facturation; ?>" />    <br /><br />

    <label for="societe" id="label_societe_facturation"> Société :</label> <br />   
    <input type="text" name="societe_facturation" id="societe" size="30" maxlength="70" tabindex="200" 
    value="<?php  echo $ligne['societe_facturation']; if(isset($societe_facturation)) echo $societe_facturation; ?>"/>    <br /><br /> 
       
    <label for="adresse" id="label_adresse_facturation"> Adresse : * </label>  <br />  
    <input type="text" name="adresse_facturation" id="adresse" size="30" maxlength="100" tabindex="210" 
    value="<?php  echo $ligne['adresse_facturation']; if(isset($adresse_facturation)) echo $adresse_facturation; ?>"/>    <br /> <br />
    
    <label for="adresse" id="label_adresse2_facturation"> Complément d'adresse : </label>  <br />
    <input type="text" name="adresse2_facturation" id="adresse2" size="30" maxlength="100" tabindex="220" 
     value="<?php  echo $ligne['adresse2_facturation']; if(isset($adresse2_facturation)) echo $adresse2_facturation; ?>"/>  <br /><br />
     
    <label for="cp" id="label_cp_facturation"> Code postal : * </label>  <br />  
    <input type="text" name="cp_facturation" id="cp" size="20" maxlength="30" tabindex="230" 
     value="<?php  echo $ligne['cp_facturation']; if(isset($cp_facturation)) echo $cp_facturation; ?>"/>    <br /><br /> 
    
    <label for="ville" id="label_ville_facturation"> Ville : * </label>  <br />  
    <input type="text" name="ville_facturation" id="ville" size="30" maxlength="100" tabindex="240" 
     value="<?php  echo $ligne['ville_facturation']; if(isset($ville_facturation)) echo $ville_facturation; ?>"/>    <br /><br />
    
    <label for="cpays" id="label_pays_facturation"> Pays : * </label>  <br />  
    <input type="text" name="pays_facturation" id="pays" size="30" maxlength="100" tabindex="250" 
     value="<?php  echo $ligne['pays_facturation']; if(isset($pays_facturation)) echo $pays_facturation; ?>"/>    <br /><br />
    
    
     <label for="email" id="label_email_facturation"> Email : * </label> <br />   
    <input type="text" name="email_facturation" id="email_facturation" size="30" maxlength="70" tabindex="260"
     value="<?php  echo $ligne['email_facturation']; if(isset($email_facturation)) echo $email_facturation; ?>" />    <br /><br />
    
    <label for="tel" id="label_tel_facturation"> Téléphone : *</label><br />    
    <input type="text" name="tel_facturation" id="tel" placeholder=" 10 chiffres sans espace" size="30" maxlength="70" tabindex="270" 
     value="<?php  echo $ligne['tel_facturation']; if(isset($tel_facturation)) echo $tel_facturation; ?>"/>   

<?php 
}
 

}else {header('Location:stop_connection-requise.php');} ?>
 </p>
      <br /><br />
    <input type="submit" name="submit2_update" id="submit2" value="Modifier"   tabindex="280" />


  </fieldset> 
</div>
</form>
</div>

 
</div>

</div>




<div class="adresse"> <span class="pivoine_adresse"> Pivoine Mercerie</span><br /> 
8, Rue des Marcassins<br />
 47200 Marmande</div>

<?php 
if(isset($_POST['submit_update']) && !empty($_POST['submit_update'])  ) 
 { $valid = true;   
   $pseudo=htmlspecialchars(trim($_POST["pseudo"])); 
   $password=htmlspecialchars(trim($_POST["password"])); 
   $password=md5($password); 
   $repeatpassword=htmlspecialchars(trim($_POST["repeatpassword"])); 
   $email=htmlspecialchars(trim($_POST["email"]));
   $civilite=htmlspecialchars(trim($_POST["civilite"])); 
   $nom=htmlspecialchars(trim($_POST["nom"])); 
   $prenom=htmlspecialchars(trim($_POST["prenom"])); 
   $societe=htmlspecialchars(trim($_POST["societe"])); 
   $adresse=htmlspecialchars(trim($_POST["adresse"])); 
   $adresse2=htmlspecialchars(trim($_POST["adresse2"])); 
   $cp=htmlspecialchars(trim($_POST["cp"])); 
   $ville=htmlspecialchars(trim($_POST["ville"]));   
   $pays=htmlspecialchars(trim($_POST["pays"]));        
   $tel=htmlspecialchars(trim($_POST["tel"]));       

	if ( empty($_POST['password']))
	   {$valid=false;
		$erreurpassword = "Mot de passe requis";
	   }
	
	if ( strlen($_POST['password']) <6 )
	   {$valid=false;
		$erreurpassword = "6 caractères minimum";
	   }
	   
	if ( empty($_POST['repeatpassword']))
	   {$valid=false;
		$erreurpassword2 = "Répétez votre mot de passe";
	   }
	
	if ($_POST['repeatpassword'] != $_POST['repeatpassword'])
	   {$valid=false;
		$erreurpassword2 = "Les mots de passe doivent être identiques";
	   }else{$password=md5($password);}
	   
	   
 
	   
	if ( empty($_POST['civilite']))
	   {$valid=false;
		$erreurcivilite = "Veuillez indiquer votre civilité";
	   }
	
	if ( empty($_POST['nom']))
	   {$valid=false;
		$erreurnom = "Veuillez indiquer votre nom";
	   }
	
	if ( empty($_POST['prenom']))
	   {$valid=false;
		$erreurprenom =  "Veuillez indiquer votre prénom";
	   }
	   
	if ( empty($_POST['adresse']))
	   {$valid=false;
		$erreuradresse = "Veuillez indiquer votre adresse";
	   }
	   
	if ( empty($_POST['cp']))
	   {$valid=false;
		$erreurcp = "Veuillez indiquer votre code postal";
	   }
	      
    if ( empty($_POST['ville']))
       {$valid = false;
        $erreurville = "Veuillez indiquer votre ville";
       }

	if ( empty($_POST['pays']))
	   {$valid=false;
		$erreurpays = "Veuillez indiquer votre pays";
	   }
	   
	if ( empty($_POST['tel']))
       {$valid=false;
        $erreurtel = "Veuillez indiquer votre numéro de téléphone";
       }
	if (!preg_match(" '([-. ]?[0-9]{2}){4}' ", $_POST['tel']))   
	   {$valid=false;
	    $erreurtel = " 10 chiffres requis";
	   }  
	   


    if (isset($valid))
	   
	   { include('mysql_connect_pivoine.php');
	           $pseudo=mysql_real_escape_string($_POST["pseudo"]); 
			   $password=mysql_real_escape_string($_POST["password"]); 
			   $password=md5($password); 
			   $repeatpassword=mysql_real_escape_string($_POST["repeatpassword"]); 
			   $email=mysql_real_escape_string($_POST["email"]);
			   $civilite=mysql_real_escape_string($_POST["civilite"]); 
			   $nom=mysql_real_escape_string($_POST["nom"]); 
			   $prenom=mysql_real_escape_string($_POST["prenom"]); 
			   $societe=mysql_real_escape_string($_POST["societe"]); 
			   $adresse=mysql_real_escape_string($_POST["adresse"]); 
			   $adresse2=mysql_real_escape_string($_POST["adresse2"]); 
			   $cp=mysql_real_escape_string($_POST["cp"]); 
			   $ville=mysql_real_escape_string($_POST["ville"]);   
			   $pays=mysql_real_escape_string($_POST["pays"]);        
			   $tel=mysql_real_escape_string($_POST["tel"]);  
			  
			    
		 mysql_query("UPDATE users SET  pseudo='$pseudo', password='$password', email='$email', civilite='$civilite', nom='$nom', prenom='$prenom',  
		          societe='$societe', adresse='$adresse', adresse2='$adresse2', cp='$cp', ville='$ville', pays='$pays',  tel='$tel'  
				  WHERE id='".$_SESSION['id']."' ") or die(mysql_error() );
			
		  mysql_close($mysql_connect_pivoine);
		header('Location:mon_compte_update_ok.php');
		 
		} 
        
}
   
/**************************************************** form SUBMIT2_update FACTURATION DIFFERENTE  ******************************************************************/
elseif(isset($_POST['submit2_update']) && !empty($_POST['submit2_update'])) 
{

   $valid = true;
    $pseudo=htmlspecialchars(trim($_POST["pseudo"])); 
	   $password=htmlspecialchars(trim($_POST["password"])); 
	   $password=md5($password); 
	   $repeatpassword=htmlspecialchars(trim($_POST["repeatpassword"])); 
	   $email=htmlspecialchars(trim($_POST["email"]));
	   $civilite=htmlspecialchars(trim($_POST["civilite"])); 
	   $nom=htmlspecialchars(trim($_POST["nom"])); 
	   $prenom=htmlspecialchars(trim($_POST["prenom"])); 
	   $societe=htmlspecialchars(trim($_POST["societe"])); 
	   $adresse=htmlspecialchars(trim($_POST["adresse"])); 
	   $adresse2=htmlspecialchars(trim($_POST["adresse2"])); 
	   $cp=htmlspecialchars(trim($_POST["cp"])); 
	   $ville=htmlspecialchars(trim($_POST["ville"]));   
	   $pays=htmlspecialchars(trim($_POST["pays"]));        
	   $tel=htmlspecialchars(trim($_POST["tel"]));  
 	   
       $civilite_facturation=htmlspecialchars(trim($_POST["civilite_facturation"])); 
	   $nom_facturation=htmlspecialchars(trim($_POST["nom_facturation"])); 
	   $prenom_facturation=htmlspecialchars(trim($_POST["prenom_facturation"])); 
	   $societe_facturation=htmlspecialchars(trim($_POST["societe_facturation"])); 
	   $adresse_facturation=htmlspecialchars(trim($_POST["adresse_facturation"])); 
	   $adresse2_facturation=htmlspecialchars(trim($_POST["adresse2_facturation"])); 
	   $cp_facturation=htmlspecialchars(trim($_POST["cp_facturation"])); 
	   $ville_facturation=htmlspecialchars(trim($_POST["ville_facturation"]));   
	   $pays_facturation=htmlspecialchars(trim($_POST["pays_facturation"]));   
	   $email_facturation=htmlspecialchars(trim($_POST["email_facturation"]));   
	   $tel_facturation=htmlspecialchars(trim($_POST["tel_facturation"]));  

 
	if (empty($_POST['password']))
	   {$valid=false;
		$erreurpassword = "Mot de passe requis";
	   }
	
	if ( strlen($_POST['password']) <6 )
	   {$valid=false;
		$erreurpassword = "6 caractères minimum";
	   }
	   
	if ( empty($_POST['repeatpassword']))
	   {$valid=false;
		$erreurpassword2 = "Répétez votre mot de passe";
	   }
	
	if ($_POST['repeatpassword'] != $_POST['repeatpassword'])
	   {$valid=false;
		$erreurpassword2 = "Les mots de passe doivent être identiques";
	   }else{$password=md5($password);}
	   
	   
	if (! preg_match( "#[a-z0-9._-]+@[a-z0-9._-][^@]+\.[a-z]{2,3}#", $_POST['email']))  /* '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#'*/
	   {$valid=false;
	   $erreuremail = "Votre adresse e-mail n'est pas valide";
	   }
	   
	if ( empty($_POST['civilite']))
	   {$valid=false;
		$erreurcivilite = "Veuillez indiquer votre civilité";
	   }
	
	if ( empty($_POST['nom']))
	   {$valid=false;
		$erreurnom = "Veuillez indiquer votre nom";
	   }
	
	if ( empty($_POST['prenom']))
	   {$valid=false;
		$erreurprenom =  "Veuillez indiquer votre prénom";
	   }
	   
	if ( empty($_POST['adresse']))
	   {$valid=false;
		$erreuradresse = "Veuillez indiquer votre adresse";
	   }
	   
	if ( empty($_POST['cp']))
	   {$valid=false;
		$erreurcp = "Veuillez indiquer votre code postal";
	   }
	      
    if ( empty($_POST['ville']))
       {$valid = false;
        $erreurville = "Veuillez indiquer votre ville";
       }

	if ( empty($_POST['pays']))
	   {$valid=false;
		$erreurpays = "Veuillez indiquer votre pays";
	   }
	      
	if ( empty($_POST['tel']))
       {$valid=false;
        $erreurtel = "Veuillez indiquer votre numéro de téléphone";
       }
	if (!preg_match(" '([-. ]?[0-9]{2}){4}' ", $_POST['tel']))   
	   {$valid=false;
	    $erreurtel = " 10 chiffres";
	   }  
	   
	   
if ( empty($_POST['civilite_facturation']))
	   {$valid=false;
		$erreurcivilite_facturation = "Champ à renseigner";        
	   }
	
	if ( empty($_POST['nom_facturation']))
	   {$valid=false;
		$erreurnom_facturation = "Champ à renseigner";
	   }
	
	if ( empty($_POST['prenom_facturation']))
	   {$valid=false;
		$erreurprenom_facturation =  "Champ à renseigner";
	   }
	   
	if ( empty($_POST['adresse_facturation']))
	   {$valid=false;
		$erreuradresse_facturation = "Champ à renseigner";
	   }
	   
	if ( empty($_POST['cp_facturation']))
	   {$valid=false;
		$erreurcp_facturation = "Champ à renseigner";
	   }
	      
    if (  empty($_POST['ville_facturation']))
       {$valid = false;
        $erreurville_facturation = "Champ à renseigner";
       }

	if ( empty($_POST['pays_facturation']))
	   {$valid=false;
		$erreurpays_facturation = "Champ à renseigner";
	   }
	   
    if ( empty($_POST['email_facturation']))
       {$valid=false;
        $erreuremail_facturation = "Champ à renseigner";
       }
	   
	if (! preg_match( "#[a-z0-9._-]+@[a-z0-9._-][^@]+\.[a-z]{2,3}#", $_POST['email_facturation']))  /* '#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#'*/
	   {$valid=false;
	   $erreuremail_facturation = "Cette adresse e-mail n'est pas valide";
	   }
	   
	if (empty($_POST['tel_facturation']))
       {$valid=false;
        $erreurtel_facturation = "Veuillez indiquer votre numéro de téléphone";
       }
	if (!preg_match(" '([-. ]?[0-9]{2}){4}' ", $_POST['tel_facturation']))   
	   {$valid=false;
	    $erreurtel_facturation = " 10 chiffres";
	   }  

    if (isset($valid))
	   { include('mysql_connect_pivoine.php');	
	      $pseudo=mysql_real_escape_string($_POST["pseudo"]); 
		   $password=mysql_real_escape_string($_POST["password"]);
		   $password=md5($password); 
		   $repeatpassword=mysql_real_escape_string($_POST["repeatpassword"]); 
		   $email=mysql_real_escape_string($_POST["email"]);
		   $civilite=mysql_real_escape_string($_POST["civilite"]); 
		   $nom=mysql_real_escape_string($_POST["nom"]); 
		   $prenom=mysql_real_escape_string($_POST["prenom"]); 
		   $societe=mysql_real_escape_string($_POST["societe"]); 
		   $adresse=mysql_real_escape_string($_POST["adresse"]); 
		   $adresse2=mysql_real_escape_string($_POST["adresse2"]); 
		   $cp=mysql_real_escape_string($_POST["cp"]); 
		   $ville=mysql_real_escape_string($_POST["ville"]);   
		   $pays=mysql_real_escape_string($_POST["pays"]);        
		   $tel=mysql_real_escape_string($_POST["tel"]);      
		
		   $civilite_facturation=mysql_real_escape_string($_POST["civilite_facturation"]); 
		   $nom_facturation=mysql_real_escape_string($_POST["nom_facturation"]); 
		   $prenom_facturation=mysql_real_escape_string($_POST["prenom_facturation"]); 
		   $societe_facturation=mysql_real_escape_string($_POST["societe_facturation"]); 
		   $adresse_facturation=mysql_real_escape_string($_POST["adresse_facturation"]); 
		   $adresse2_facturation=mysql_real_escape_string($_POST["adresse2_facturation"]); 
		   $cp_facturation=mysql_real_escape_string($_POST["cp_facturation"]); 
		   $ville_facturation=mysql_real_escape_string($_POST["ville_facturation"]);   
		   $pays_facturation=mysql_real_escape_string($_POST["pays_facturation"]);   
		   $email_facturation=mysql_real_escape_string($_POST["email_facturation"]);   
		   $tel_facturation=mysql_real_escape_string($_POST["tel_facturation"]);  
	
		 mysql_query("UPDATE users SET  pseudo='$pseudo', password='$password', email='$email', civilite='$civilite', nom='$nom', prenom='$prenom',  
		          societe='$societe', adresse='$adresse', adresse2='$adresse2', cp='$cp', ville='$ville', pays='$pays',  tel='$tel',  
				  civilite_facturation='$civilite_facturation', nom_facturation='$nom_facturation', prenom_facturation='$prenom_facturation', 
				  societe_facturation='$societe_facturation', adresse_facturation='$adresse_facturation', adresse2_facturation='$adresse2_facturation', 
				  cp_facturation='$cp_facturation', ville_facturation='$ville_facturation', pays_facturation='$pays_facturation',  
				  email_facturation='$email_facturation', tel_facturation='$tel_facturation' 
		          WHERE pseudo='$pseudo'  ") 
		 or die(mysql_error() );
		  mysql_close($mysql_connect_pivoine);
		 header('Location:mon_compte_update_ok.php');
		
		} 
        
	   	 
		
		
		
 }  

else {$valid =false; } 
?>
       



</div>
</body>
</html>


Modifié par Vape6 (29 Sep 2013 - 17:32)