Problème envoi email

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Problème envoi email

Problème envoi email

par sylvaing26 » 03 nov. 2008, 20:55

Bonjour,
je souhaiterai envoyer une commande par email seulement je ne sais pas comment integrer une boucle pour ecrire dans le message les ref etc ...
j'ai bien créé une fonction mais lorsque je met echo ca ecrit dans le code de la page
voici mon code
<?php
session_start();
include("connect_panier.php");
@MYSQL_CONNECT($serveur,$utilisateur,$mdp) or die ("Connexion impossible");
@MYSQL_SELECT_DB($db) or die ("Connexion à la base $base impossible");
if(!isset($_SESSION['commande'])){
$_SESSION['commande'] = array(); 
/* Subdivision du panier */ 
$_SESSION['commande']['id'] = array(); 
$sql = mysql_query("SELECT * FROM numero ORDER BY numero DESC LIMIT 0,1");
while($result=mysql_fetch_array($sql)){
$id = $result['numero'];
$nouvel_id = $id + 1;
array_push($_SESSION['commande']['id'],$nouvel_id);
mysql_query("UPDATE `numero` SET `numero` = '$nouvel_id' WHERE `numero` = '$id' LIMIT 1") ;
}
$numero_commande = $_SESSION['commande']['id'][0];
mysql_query("CREATE TABLE `$numero_commande` (`id` INT NOT NULL AUTO_INCREMENT ,`ref` TEXT NOT NULL ,`nom` TEXT NOT NULL ,`quantite` TEXT NOT NULL ,`prix` TEXT NOT NULL ,PRIMARY KEY ( `id` ) 
) TYPE = MYISAM");
mysql_close();
}

$num = $_SESSION['commande']['id'][0];

function articles($num)
{	
include("connect_panier.php");
$num = $_SESSION['commande']['id'][0];
    MYSQL_CONNECT($serveur,$utilisateur,$mdp) or die ("Connexion impossible");
    MYSQL_SELECT_DB($db) or die ("Connexion à la base $base impossible");
    
    $sql2 = mysql_query("SELECT * FROM `$num` ORDER BY 'id' ASC");
    while($result=mysql_fetch_array($sql2)){
    $id = $result['id'];
    $ref = $result['ref'];
    $nom = $result['nom'];
    $quantite = $result['quantite'];
    $prix_unitaire = $result['prix'];
    $prix_point = str_replace(chr(44),chr(46),$prix_unitaire);
    $prix = $prix_point * $quantite;
    $prix = number_format($prix, 2, ',', ' ');
    echo "REF : $ref \n";
    include("connect.php");
MYSQL_CONNECT($serveur,$utilisateur,$mdp) or die ("Connexion impossible");
MYSQL_SELECT_DB($db) or die ("Connexion à la base $base impossible");
$sql = mysql_query("SELECT page FROM coupes_trophees WHERE reference LIKE '$ref' OR ref2 LIKE '$ref' OR ref3 LIKE '$ref'OR ref4 LIKE '$ref' ");
$nbr=mysql_num_rows($sql);
if($nbr > 0){
while($result=mysql_fetch_array($sql)){
$page = $result['page'];
}
echo "PAGE $page \n";
    }
echo "QUANTITE : $quantite \n";
echo "PRIX UNITAIRE : $prix_unitaire Euros\n";
echo "PRIX TOTAL : $prix Euros\n";
echo " -------- \n\n";
}

    MYSQL_CONNECT($serveur,$utilisateur,$mdp) or die ("Connexion impossible");
    MYSQL_SELECT_DB($db) or die ("Connexion à la base $base impossible");
    $num = $_SESSION['commande']['id'][0];
    $sql2 = mysql_query("SELECT * FROM `$num` ORDER BY 'id' ASC");
    $total=0;
    while($result=mysql_fetch_array($sql2)){
    $id = $result['id'];
    $ref = $result['ref'];
    $nom = $result['nom'];
    $quantite = $result['quantite'];
    $prix_unitaire = $result['prix'];
    $prix_point = str_replace(chr(44),chr(46),$prix_unitaire);
    $prix = $prix_point * $quantite;
    $total=$prix + $total;
    $prix = number_format($prix, 2, ',', ' ');
    
    }
    $total = number_format($total, 2, ',', ' ');
    echo "TOTAL COMMANDE $total EUROS \n";
}


$nom = $_POST['nom'];
$mail = $_POST['mail'];
$telephone = $_POST['telephone'];
$adresse = $_POST['adresse'];
$code_postal = $_POST['code_postal'];
$ville = $_POST['ville'];    
if (($mail!="") && ($nom!="") && ($telephone!="") && ($adresse!="") && ($code_postal!="") && ($ville!=""))
  {
      // composition du message
      $Sujet="Commande CTM\n";
      $MailTo="[email protected]";
      $mailheaders = "From: <$mail> \n";
      $mailheaders .= "Reply-To: <$mail>\n\n";
      include("connect_panier.php");
      $num = $_SESSION['commande']['id'][0];
      $articles = articles($num);
      $msg = "NOUVELLE COMMANDE\n\n$nom \n$adresse \n$code_postal $ville \nTéléphone : $telephone \nArticles : $articles\n";
      // fonction d envoi du message
      $mail_OK=mail($MailTo, $Sujet, $msg, $mailheaders);
      // renvoit envoi_reussi a 1 si le mail a été envoyé
      // et 0 dans le cas contraire !
      echo "<meta http-equiv=\"refresh\" content=\"2;url=http://coupesetgravures.com/validation2.php\">";
  }
?>