8796 sujets

Développement web côté serveur, CMS

bonjour à tous;

dans mon site j'ai une page "panier.php" dans laquelle j'ai mis deux bouton, un pour valider la quantité des articles choisi par le client dans la liste deroulante et le 2eme c'est pour valider et envoyer votre commande par mail à l'administrateur; mais le probleme qui se pose c'est que quand je clique sur valider la quantité il envoie 2 mail à l'administrateur et il fait pareil aussi quand j'actualise juste la page, et quand je clique su valider et envoyer le bon de commande par mail il m'envoie aussi un mail et il valide la commande.
vous trouvez ci_dessous mon script , et svp si quelqu'un peut me dire comment je peux faire pour que l'administrateur ne reçoit l'email que quand le client clique sur le boutton valider et envoyer votre commande par mail . merci d'avance pour votre aide

     <table width="99%" border="1" class="Style16" >
                  <tr>
                    <td   class="Style16" width="140">Article</td>
                    <td   class="Style16" width="101">Prix unitaire </td>
                    <td class="Style16" width="445">Quantité</td>
                    <td class="Style16" width="151">Prix total</td>
                  </tr>
                  <?php do { ?>
                  <?php
		$prix_ht =$row_panier['prix_ht'];
		$total_ht =$row_panier['total_ht'];	
		$prix_ht_arrondi= number_format($prix_ht, 2, ',', ' '); 		
		$total_ht_arrondi= number_format($total_ht, 2, ',', ' '); 	
	?>
                  <tr>
                    <td class="Style16" width="140"><?php echo $row_panier['titre']; ?> </td>
                    <td class="Style16" width="101"><?php echo $prix_ht_arrondi ?> €</td>
                    <td class="Style16" width="445"><form action="<?php echo $editFormAction; ?>" method="POST" name="Quantite">
                        <p>
                          <input name="id" type="hidden" value="<?php echo $row_panier['id'];?>" />
                          <input name="client" type="hidden" value="<?php echo $row_panier['client'];?>" />
                          <input name="article" type="hidden" value="<?php echo $row_panier['article'];?>" />
                          <select name="quantite" >
                            <option value="<?php echo $row_panier['quantite']; ?>" ><?php echo $row_panier['quantite']; ?></option>
                            <option >1</option>
                            <option >2</option>
                            <option >3</option>
                            <option >4</option>
                            <option >5</option>
                            <option >6</option>
                            <option >7</option>
                            <option >8</option>
                            <option >9</option>
                            <option >10</option>
                          </select>
                          <?php /*?> <input name="quantite" type="text" value="<?php echo $row_panier['quantite']; ?>" size="2" /><?php */?>
                          <input name="Submit" type="submit" value="Valider la quantité" />
                        </p>
                      <input type="hidden" name="MM_update" value="Quantite" />
                        <!--envoie la quantité à mettre à jour-->
                      </form>
                        <p><a href="suppr_panier.php?id=<?php echo $row_panier['id'];?>"onclick="if(window.confirm('Etes vous sur ?')){return true;}else{return false;}">Supprimer cet article</a> </p></td>
                    <td class="Style16" width="151" ><?php echo $total_ht_arrondi ?>€</td>
                  </tr>
                  <?php } while ($row_panier = mysql_fetch_assoc($panier)); ?>
                  <?php
  	$poids = $row_Total['poids'];
	$total_ttc = $row_Total['total_ttc'];
	$fdp1 = $row_fdp['prix1'];
	$fdp2 = $row_fdp['prix2'];
	$fdp3 = $row_fdp['prix3'];
	$fdp4 = $row_fdp['prix4'];
	
  	if ($poids > 1 && $poids <= 3000) {
	$fdp = $fdp1;
	$total_final = $fdp + $total_ttc;
	$total_final_arrondi= number_format($total_final, 2, ',', ' '); 
	}
else if ($poids > 3000 && $poids <= 5000) {
	$fdp = $fdp2;
	$total_final = $fdp  + $total_ttc;
	$total_final_arrondi= number_format($total_final, 2, ',', ' '); 
	}
else if ($poids > 5000 && $poids <= 7000) {
	$fdp = $fdp3;
	$total_final = $fdp  + $total_ttc;
	$total_final_arrondi= number_format($total_final, 2, ',', ' ');  
	}
else if ($poids > 7000){
	$fdp = $fdp4;
	$total_final = $fdp  + $total_ttc;
	$total_final_arrondi= number_format($total_final, 2, ',', ' '); 
	}
?>
                  <tr>
                    <td rowspan="4" colspan="2" class="Style20"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#990000"><b>Ajouter un  
                      commentaire &agrave;  la commande:</b></font><br/>
                                        <textarea name="ajouter" cols="30" rows="4">
                      </textarea></td>
                    <td class="Style16">Total HT</td>
                    <td class="Style16"><?php echo $row_Total['total_ht']; ?>€</td>
                  </tr>
                  <tr>
                    <td class="Style16">Sous_total</td>
                    <td class="Style16"><?php echo $row_Total['total_ttc']; ?>€</td>
                  </tr>
                  <tr>
                    <td class="Style16">Forfait transport</td>
                    <td class="Style16"><?php echo $fdp  ?> €</td>
                  </tr>
                  <tr>
                    <td class="Style16">Total TTC </td>
                    <td class="Style16"><?php echo $total_final_arrondi ?> €</td>
                  </tr>
                </table>
          <table width="824" height="18" border="0" cellspacing="0" cellpadding="0">
                </table>
          <p align="center"> <a href = "../catalogue.php">Continuer vos achats</a></p>
$liste = 'maildenvoie.fr';
  

$destinataire = 'administrateur@yahoo.fr'; //on adresse une copie a l'administrateur
 
$date = date("d/m/Y");
 
$objet = "Bon de commande du $date"; //on définit l'objet qui contient la date
 
//on définit le reste des paramètres
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: maildenvoie.fr' . "\r\n"; //on définit l'expéditeur

$fichier_message = '<html>
<body bgcolor="green">
<font face="green"><font color="black"><font size="5"><p align="center"><b><span><font color="green"><u>BON DE COMMANDE </u></font></span></b></p></font>
<font size="4">' . $_POST['message'] . '<br /><br />
<p align="left">Bonjour :<br /> Vous trouvez ci_ joint le bon de commande <ul>'; //on définit le message
 
   
 
$fichier_message .= '</ul></body>
</html>'; //on termine le message
    //on envoie l'e-mail
	ini_set("sendmail_from","maildenvoie.fr");
    if ( mail($destinataire, $objet, $fichier_message, $headers) ) 
    { 
?>
                        <?php 
    }
    else
    {
?>
                      Échec de lors de l'envoi du bon de commande.
                      <?php
    }
 //Fin de la condition de validité du formulaire
?>
                      <form action = "<?php echo $editFormAction; ?>" method="POST" name="Validation" class="Style21" onsubmit="return window.confirm('Etes vous sur de valider votre commande?');">
                        <p>
                          <input name="date" type="hidden" value="<?php echo $row_Total['date'];?>" />
                          <input name="poids" type="hidden" value="<?php echo $row_Total['poids'];?>" />
                          <input name="total_ht" type="hidden" value="<?php echo $row_Total['total_ht'];?>" />
                          <input name="total_ttc" type="hidden" value="<?php echo $row_Total['total_ttc'];?>" />
                          <input name="client" type="hidden" value="<?php echo $_SESSION['MM_Username']; ?>" />
                          <input name="expedition" type="hidden" value="<?php echo $row_Total['expedition'];?>" />
                          <input name="Submit" type="submit" value="Valider et envoyer votre commande par mail"/>
                          <input name="MM_insert" type="hidden"value="Validation" />
                          <input type="hidden" name="MM_insert" value="Validation" />
                        </p>
                      </form></td>
                  </tr>
Bonsoir,

A part ca tu as oublier des ;
Lignes 85, 185. (C'est pas grave, mais c'est mieux si tu les mets a chaque fois)


Et après la ligne 195 il n'y a pas de balise <?php !!


C'est surtout la balise la qui manquée, j'ai pas vérifié le reste mais il n'y a pus d'erreurs.


Code avec les corrections citées:
<table width="99%" border="1" class="Style16" >

                  <tr>

                    <td   class="Style16" width="140">Article</td>

                    <td   class="Style16" width="101">Prix unitaire </td>

                    <td class="Style16" width="445">Quantité</td>

                    <td class="Style16" width="151">Prix total</td>

                  </tr>

                  <?php do { ?>

                  <?php

		$prix_ht =$row_panier['prix_ht'];

		$total_ht =$row_panier['total_ht'];	

		$prix_ht_arrondi= number_format($prix_ht, 2, ',', ' '); 		

		$total_ht_arrondi= number_format($total_ht, 2, ',', ' '); 	

	?>

                  <tr>

                    <td class="Style16" width="140"><?php echo $row_panier['titre']; ?> </td>

                    <td class="Style16" width="101"><?php echo $prix_ht_arrondi ?> €</td>

                    <td class="Style16" width="445"><form action="<?php echo $editFormAction; ?>" method="POST" name="Quantite">

                        <p>

                          <input name="id" type="hidden" value="<?php echo $row_panier['id'];?>" />

                          <input name="client" type="hidden" value="<?php echo $row_panier['client'];?>" />

                          <input name="article" type="hidden" value="<?php echo $row_panier['article'];?>" />

                          <select name="quantite" >

                            <option value="<?php echo $row_panier['quantite']; ?>" ><?php echo $row_panier['quantite']; ?></option>

                            <option >1</option>

                            <option >2</option>

                            <option >3</option>

                            <option >4</option>

                            <option >5</option>

                            <option >6</option>

                            <option >7</option>

                            <option >8</option>

                            <option >9</option>

                            <option >10</option>

                          </select>

                          <?php /*?> <input name="quantite" type="text" value="<?php echo $row_panier['quantite']; ?>" size="2" /><?php */?>

                          <input name="Submit" type="submit" value="Valider la quantité" />

                        </p>

                      <input type="hidden" name="MM_update" value="Quantite" />

                        <!--envoie la quantité à mettre à jour-->

                      </form>

                        <p><a href="suppr_panier.php?id=<?php echo $row_panier['id'];?>"onclick="if(window.confirm('Etes vous sur ?')){return true;}else{return false;}">Supprimer cet article</a> </p></td>

                    <td class="Style16" width="151" ><?php echo $total_ht_arrondi; ?>€</td>

                  </tr>

                  <?php } while ($row_panier = mysql_fetch_assoc($panier)); ?>

                  <?php

  	$poids = $row_Total['poids'];

	$total_ttc = $row_Total['total_ttc'];

	$fdp1 = $row_fdp['prix1'];

	$fdp2 = $row_fdp['prix2'];

	$fdp3 = $row_fdp['prix3'];

	$fdp4 = $row_fdp['prix4'];

	

  	if ($poids > 1 && $poids <= 3000) {

	$fdp = $fdp1;

	$total_final = $fdp + $total_ttc;

	$total_final_arrondi= number_format($total_final, 2, ',', ' '); 

	}

else if ($poids > 3000 && $poids <= 5000) {

	$fdp = $fdp2;

	$total_final = $fdp  + $total_ttc;

	$total_final_arrondi= number_format($total_final, 2, ',', ' '); 

	}

else if ($poids > 5000 && $poids <= 7000) {

	$fdp = $fdp3;

	$total_final = $fdp  + $total_ttc;

	$total_final_arrondi= number_format($total_final, 2, ',', ' ');  

	}

else if ($poids > 7000){

	$fdp = $fdp4;

	$total_final = $fdp  + $total_ttc;

	$total_final_arrondi= number_format($total_final, 2, ',', ' '); 

	}

?>

                  <tr>

                    <td rowspan="4" colspan="2" class="Style20"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#990000"><b>Ajouter un  

                      commentaire &agrave;  la commande:</b></font><br/>

                                        <textarea name="ajouter" cols="30" rows="4">

                      </textarea></td>

                    <td class="Style16">Total HT</td>

                    <td class="Style16"><?php echo $row_Total['total_ht']; ?>€</td>

                  </tr>

                  <tr>

                    <td class="Style16">Sous_total</td>

                    <td class="Style16"><?php echo $row_Total['total_ttc']; ?>€</td>

                  </tr>

                  <tr>

                    <td class="Style16">Forfait transport</td>

                    <td class="Style16"><?php echo $fdp  ?> €</td>

                  </tr>

                  <tr>

                    <td class="Style16">Total TTC </td>

                    <td class="Style16"><?php echo $total_final_arrondi; ?> €</td>

                  </tr>

                </table>

          <table width="824" height="18" border="0" cellspacing="0" cellpadding="0">

                </table>

          <p align="center"> <a href = "../catalogue.php">Continuer vos achats</a></p>
<?php
$liste = 'maildenvoie.fr';

  



$destinataire = 'administrateur@yahoo.fr'; //on adresse une copie a l'administrateur

 

$date = date("d/m/Y");

 

$objet = "Bon de commande du $date"; //on définit l'objet qui contient la date

 

//on définit le reste des paramètres

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= 'From: maildenvoie.fr' . "\r\n"; //on définit l'expéditeur



$fichier_message = '<html>

<body bgcolor="green">

<font face="green"><font color="black"><font size="5"><p align="center"><b><span><font color="green"><u>BON DE COMMANDE </u></font></span></b></p></font>

<font size="4">' . $_POST['message'] . '<br /><br />

<p align="left">Bonjour :<br /> Vous trouvez ci_ joint le bon de commande <ul>'; //on définit le message

 

   

 

$fichier_message .= '</ul></body>

</html>'; //on termine le message

    //on envoie l'e-mail

	ini_set("sendmail_from","maildenvoie.fr");

    if ( mail($destinataire, $objet, $fichier_message, $headers) ) 

    { 

?>

                        <?php 

    }

    else

    {

?>

                      Échec de lors de l'envoi du bon de commande.

                      <?php

    }

 //Fin de la condition de validité du formulaire

?>

                      <form action = "<?php echo $editFormAction; ?>" method="POST" name="Validation" class="Style21" onsubmit="return window.confirm('Etes vous sur de valider votre commande?');">

                        <p>

                          <input name="date" type="hidden" value="<?php echo $row_Total['date'];?>" />

                          <input name="poids" type="hidden" value="<?php echo $row_Total['poids'];?>" />

                          <input name="total_ht" type="hidden" value="<?php echo $row_Total['total_ht'];?>" />

                          <input name="total_ttc" type="hidden" value="<?php echo $row_Total['total_ttc'];?>" />

                          <input name="client" type="hidden" value="<?php echo $_SESSION['MM_Username']; ?>" />

                          <input name="expedition" type="hidden" value="<?php echo $row_Total['expedition'];?>" />

                          <input name="Submit" type="submit" value="Valider et envoyer votre commande par mail"/>

                          <input name="MM_insert" type="hidden"value="Validation" />

                          <input type="hidden" name="MM_insert" value="Validation" />

                        </p>

                      </form></td>

                  </tr>

Modifié par xBEAD (01 Jul 2011 - 02:41)
bonjour, merci pour ta correction, je viens de l'apporter à mon script , mais le probleme reste toujours le meme, il m'envoie un mail des que j'ouvre la page panier.php et il m'envoie 2 mail quand je clique sur valider la quantité choisi dans la liste deroulante, et il m'envoie aussi un mail quand je clique sur le boutton valider et envoyer la commande par mail!!
alors que moi je dois recevoir un mail juste que quand je clique sur valider et envoyer la commande par mail!!
Il manque une condition, donc a chaque fois que tu vas sur la page sa envoi un mail.

<table width="99%" border="1" class="Style16" >



                  <tr>



                    <td   class="Style16" width="140">Article</td>



                    <td   class="Style16" width="101">Prix unitaire </td>



                    <td class="Style16" width="445">Quantité</td>



                    <td class="Style16" width="151">Prix total</td>



                  </tr>



                  <?php do { ?>



                  <?php



		$prix_ht =$row_panier['prix_ht'];



		$total_ht =$row_panier['total_ht'];	



		$prix_ht_arrondi= number_format($prix_ht, 2, ',', ' '); 		



		$total_ht_arrondi= number_format($total_ht, 2, ',', ' '); 	



	?>



                  <tr>



                    <td class="Style16" width="140"><?php echo $row_panier['titre']; ?> </td>



                    <td class="Style16" width="101"><?php echo $prix_ht_arrondi ?> €</td>



                    <td class="Style16" width="445"><form action="<?php echo $editFormAction; ?>" method="POST" name="Quantite">



                        <p>



                          <input name="id" type="hidden" value="<?php echo $row_panier['id'];?>" />



                          <input name="client" type="hidden" value="<?php echo $row_panier['client'];?>" />



                          <input name="article" type="hidden" value="<?php echo $row_panier['article'];?>" />



                          <select name="quantite" >



                            <option value="<?php echo $row_panier['quantite']; ?>" ><?php echo $row_panier['quantite']; ?></option>



                            <option >1</option>



                            <option >2</option>



                            <option >3</option>



                            <option >4</option>



                            <option >5</option>



                            <option >6</option>



                            <option >7</option>



                            <option >8</option>



                            <option >9</option>



                            <option >10</option>



                          </select>



                          <?php /*?> <input name="quantite" type="text" value="<?php echo $row_panier['quantite']; ?>" size="2" /><?php */?>



                          <input name="Submit" type="submit" value="Valider la quantité" />



                        </p>



                      <input type="hidden" name="MM_update" value="Quantite" />



                        <!--envoie la quantité à mettre à jour-->



                      </form>



                        <p><a href="suppr_panier.php?id=<?php echo $row_panier['id'];?>"onclick="if(window.confirm('Etes vous sur ?')){return true;}else{return false;}">Supprimer cet article</a> </p></td>



                    <td class="Style16" width="151" ><?php echo $total_ht_arrondi; ?>€</td>



                  </tr>



                  <?php } while ($row_panier = mysql_fetch_assoc($panier)); ?>



                  <?php



  	$poids = $row_Total['poids'];



	$total_ttc = $row_Total['total_ttc'];



	$fdp1 = $row_fdp['prix1'];



	$fdp2 = $row_fdp['prix2'];



	$fdp3 = $row_fdp['prix3'];



	$fdp4 = $row_fdp['prix4'];



	



  	if ($poids > 1 && $poids <= 3000) {



	$fdp = $fdp1;



	$total_final = $fdp + $total_ttc;



	$total_final_arrondi= number_format($total_final, 2, ',', ' '); 



	}



else if ($poids > 3000 && $poids <= 5000) {



	$fdp = $fdp2;



	$total_final = $fdp  + $total_ttc;



	$total_final_arrondi= number_format($total_final, 2, ',', ' '); 



	}



else if ($poids > 5000 && $poids <= 7000) {



	$fdp = $fdp3;



	$total_final = $fdp  + $total_ttc;



	$total_final_arrondi= number_format($total_final, 2, ',', ' ');  



	}



else if ($poids > 7000){



	$fdp = $fdp4;



	$total_final = $fdp  + $total_ttc;



	$total_final_arrondi= number_format($total_final, 2, ',', ' '); 



	}



?>



                  <tr>



                    <td rowspan="4" colspan="2" class="Style20"><font face="Verdana, Arial, Helvetica, sans-serif" size="2" color="#990000"><b>Ajouter un  



                      commentaire &agrave;  la commande:</b></font><br/>



                                        <textarea name="ajouter" cols="30" rows="4">



                      </textarea></td>



                    <td class="Style16">Total HT</td>



                    <td class="Style16"><?php echo $row_Total['total_ht']; ?>€</td>



                  </tr>



                  <tr>



                    <td class="Style16">Sous_total</td>



                    <td class="Style16"><?php echo $row_Total['total_ttc']; ?>€</td>



                  </tr>



                  <tr>



                    <td class="Style16">Forfait transport</td>



                    <td class="Style16"><?php echo $fdp  ?> €</td>



                  </tr>



                  <tr>



                    <td class="Style16">Total TTC </td>



                    <td class="Style16"><?php echo $total_final_arrondi; ?> €</td>



                  </tr>



                </table>



          <table width="824" height="18" border="0" cellspacing="0" cellpadding="0">



                </table>



          <p align="center"> <a href = "../catalogue.php">Continuer vos achats</a></p>

<?php

$liste = 'maildenvoie.fr';



  







$destinataire = 'administrateur@yahoo.fr'; //on adresse une copie a l'administrateur



 



$date = date("d/m/Y");



 



$objet = "Bon de commande du $date"; //on définit l'objet qui contient la date



 



//on définit le reste des paramètres



$headers  = 'MIME-Version: 1.0' . "\r\n";



$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";



$headers .= 'From: maildenvoie.fr' . "\r\n"; //on définit l'expéditeur







$fichier_message = '<html>



<body bgcolor="green">



<font face="green"><font color="black"><font size="5"><p align="center"><b><span><font color="green"><u>BON DE COMMANDE </u></font></span></b></p></font>



<font size="4">' . $_POST['message'] . '<br /><br />



<p align="left">Bonjour :<br /> Vous trouvez ci_ joint le bon de commande <ul>'; //on définit le message



 



   



 



$fichier_message .= '</ul></body>



</html>'; //on termine le message



    //on envoie l'e-mail



	ini_set("sendmail_from","maildenvoie.fr");

if($_POST['id'] && $_POST['client']){

    if ( mail($destinataire, $objet, $fichier_message, $headers) ) 



    { 



?>



                        <?php 



    }



    else



    {



?>



                      Échec de lors de l'envoi du bon de commande.



                      <?php



    }
}


 //Fin de la condition de validité du formulaire



?>



                      <form action = "<?php echo $editFormAction; ?>" method="POST" name="Validation" class="Style21" onsubmit="return window.confirm('Etes vous sur de valider votre commande?');">



                        <p>



                          <input name="date" type="hidden" value="<?php echo $row_Total['date'];?>" />



                          <input name="poids" type="hidden" value="<?php echo $row_Total['poids'];?>" />



                          <input name="total_ht" type="hidden" value="<?php echo $row_Total['total_ht'];?>" />



                          <input name="total_ttc" type="hidden" value="<?php echo $row_Total['total_ttc'];?>" />



                          <input name="client" type="hidden" value="<?php echo $_SESSION['MM_Username']; ?>" />



                          <input name="expedition" type="hidden" value="<?php echo $row_Total['expedition'];?>" />



                          <input name="Submit" type="submit" value="Valider et envoyer votre commande par mail"/>



                          <input name="MM_insert" type="hidden"value="Validation" />



                          <input type="hidden" name="MM_insert" value="Validation" />



                        </p>



                      </form></td>



                  </tr>