Formation Google AnalyticsSavez-vous bien utiliser les outils de mesure d'audience ?
Effectuez-vous un calcul de ROI (Retour sur investissement) pour savoir comment améliorer vos campagnes emarketing ?
Savez-vous utiliser les bons outils pour booster votre taux de transformation ?
La formation Web Analytics de Ranking Metrics, présentée par un expert reconnu officiellement par Google Analytics, vous apportera les réponses à toutes vos questions !
===> Informations et inscriptions.

Bon de commande

Aller à la page 1, 2  Suivante
Poster un nouveau sujet Imprimer cette discussion    Forum -> Développement d'un site Web   Les dernières discussions de ce forum sont disponibles au format RSS
Voir le sujet précédent :: Voir le sujet suivant  
Auteur Message
 
aventvoy
WRInaute occasionnel
WRInaute occasionnel

Inscrit le: 17 Nov 2004
Messages: 169
Localisation: Canada

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 1:11    Sujet du message: Bon de commande

Hello,
Je cherche à mettre en place un bon de commande simple (peu de produits, pas de paiement en ligne, donc pas besoin de bdd à première vue...)
Le problème est que je n'arrive pas à obtenir le prix total en fin de commande...
exemple: le visiteur achète 2 exemplaires du produit A au format X et un exemplaire du produit B au format Y. Sachant qu'il y a mettons 10 produits, chacun disponibles dans 4 formats, et chaque format etant à un prix specifique, je veux bien sur aditionner tous les produits, et tous les prix.
Mais je n'y arrive pas...
Y aurait il un tutoriel ou un modèle exploitable caché quelque part et que je n'aurais pas vu??
Merci d'avance,
A.
 
aventvoy Visiter le site web du posteur
padawan2
WRInaute passionné
WRInaute passionné

Inscrit le: 02 Fév 2007
Messages: 532

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 2:37    Sujet du message: Bon de commande

http://www.google.com/search?source=ig&hl=en&rlz=&q=panier+javascrip...

Vu les infos que tu donnes, je ne peux pas t'en dire beaucoup plus.
Tu peux te baser sur ce qui se fait déjà en javascript pour mettre à jour le panier et calculer les prix.
Ensuite à toi de coder ce qui va autour (envoi par email ou bien création d'un PDF à imprimer,...etc)

Bon courage !
 
padawan2
aventvoy
WRInaute occasionnel
WRInaute occasionnel

Inscrit le: 17 Nov 2004
Messages: 169
Localisation: Canada

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 4:48    Sujet du message: Bon de commande

Hello padawan2,
Merci pour la réponse rapide. Le fait est que j'ai déjà codé "ce qui va autour" en php, mon "presque seul" problème est le calcul du prix.
En détail, il s'agit de photos. Chaque photo (il y en a 52...) est disponible en 4 formats différents, bien sur chaque format a son prix.
Imaginons, Mr Visiteur veut 2 photos reference A au format X/Y, et 2 photos reference B au format Z/W (je n'ose pas imaginer si il veut une photo A au format X/Y plus 2 fois la même au format Z/W...).
Bref, je ne sais pas comment compulser le tout, calculer le tarif total, et mettre en place la partie qui précise le détail de la commande dans "ce qui va autour" (envoi commande par email).
Si je fais ça avec une seule photo et 4 formats disponibles, bien sur ça va bien...
Mettre le code serait il utile ici? C'est long comme code...
Pour satisfaire les curieux, je fais ça au profit d'une association qui monte une expédition scientifique, et dont le photographe se "paye" en vendant ses photos sur le site de l'expé, qui elle se finance autrement bien sur...
 
aventvoy Visiter le site web du posteur
rog
WRInaute accro
WRInaute accro

Inscrit le: 21 Sep 2006
Messages: 1662
Localisation: sapucaia do sul (RS)

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 5:06    Sujet du message: Bon de commande

bizarre comme probleme

[quantité] [libellé] [prix unitaire] [total]

on doit d'abord renseigner la colonne total pour ensuite faire la somme

rog
 
rog Visiter le site web du posteur
Marie-Aude
WRInaute accro
WRInaute accro

Inscrit le: 05 Juin 2006
Messages: 3443
Localisation: More than a plastic girl

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 5:46    Sujet du message: Bon de commande

aventvoy a écrit:
Hello padawan2,
Merci pour la réponse rapide. Le fait est que j'ai déjà codé "ce qui va autour" en php, mon "presque seul" problème est le calcul du prix.
En détail, il s'agit de photos. Chaque photo (il y en a 52...) est disponible en 4 formats différents, bien sur chaque format a son prix.
Imaginons, Mr Visiteur veut 2 photos reference A au format X/Y, et 2 photos reference B au format Z/W (je n'ose pas imaginer si il veut une photo A au format X/Y plus 2 fois la même au format Z/W...).
Bref, je ne sais pas comment compulser le tout, calculer le tarif total, et mettre en place la partie qui précise le détail de la commande dans "ce qui va autour" (envoi commande par email).
Si je fais ça avec une seule photo et 4 formats disponibles, bien sur ça va bien...
Mettre le code serait il utile ici? C'est long comme code...
Pour satisfaire les curieux, je fais ça au profit d'une association qui monte une expédition scientifique, et dont le photographe se "paye" en vendant ses photos sur le site de l'expé, qui elle se finance autrement bien sur...


Bon si tes données sont correctement structurées, il ne devrait y avoir aucun problème.

1- Liste des photos (sans prix, bien sûr) -> identifiant unique sur la photo
2- Liste des formats, avec prix, identifiant unique sur le format
3- Liste des commandes (ou panier), avec identifiant unique
4- Lignes de commande, avec comme identifiant unique photo + format + panier, et en plus comme info la quantité

a. calculer le prix de la ligne : quantité * prix = prixligne
b. Dans une boucle stocker le prix cumulé, prixcumulé = prixcumulé + prixligne et s'arrêter quand on a fait toutes les lignes, ou bien faire un total des prix de lignes.
 
Marie-Aude Visiter le site web du posteur
aventvoy
WRInaute occasionnel
WRInaute occasionnel

Inscrit le: 17 Nov 2004
Messages: 169
Localisation: Canada

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 8:42    Sujet du message: Bon de commande

Bon, j'essaye, j'ai beau tourner le tout dans tous les sens, et je ne comprends pas...
Marie Aude, quand je lis votre message, ça me semble clair, mais en pratique, je ne m'en sors pas.
Voici ce que j'ai comme code. J'y ai mis le plus de commentaires possibles pour que j'arrive à me suivre ('Confused')
Je sais que ça ne peut pas marcher tel quel, car je ne vois pas comment calculer la somme de plusieurs variables (d'où les fausses variables $liste_ref et $nombretotal entre autres...

Code:


<?php
if(isset($_POST['envoi']))
{
    $email_dest ="mon_email@machin.com";
    $headers ="MIME-Version: 1.0 \n";
    $headers .="From: Photos Photographe <mon_email@machin.com>\n";
    $headers .="Content-Type: text/html; charset=iso-8859-1 \n";
    $subject = "Commande de photos";

    // Récupération des données du formulaire
    $genre        = $_POST['genre'];
    $prenom     = $_POST['prenom'];
    $nom          = $_POST['nom'];
    $adresse     = $_POST['adresse'];
    $ville           = $_POST['ville'];
    $code          = $_POST['code'];
    $pays          = $_POST['pays'];
    $tel             = $_POST['tel'];
    $email         = $_POST['email'];
// récupération des données de la tierce personne si c'est pour un cadeau
   $genreami       = $_POST['genreami'];
   $prenom_ami  = $_POST['prenom_ami'];
   $nom_ami       = $_POST['nom_ami'];
   $adresseami    = $_POST['adresseami'];
    $villeami         = $_POST['villeami'];
    $codeami        = $_POST['codeami'];
    $paysami         = $_POST['paysami'];
    $telami            = $_POST['telami'];
    $emailami        = $_POST['emailami'];
   // les references des photos, seulement 10 listées sur 52 disponibles... On supposera que le visiteur ne veut en commander que 10 maximum...
   $ref1       = $_POST['ref1'];
   $ref2       = $_POST['ref2'];
   $ref3       = $_POST['ref3'];
   $ref4       = $_POST['ref4'];
   $ref5       = $_POST['ref5'];
   $ref6       = $_POST['ref6'];
   $ref7       = $_POST['ref7'];
   $ref8       = $_POST['ref8'];
   $ref9       = $_POST['ref9'];
   $ref10      = $_POST['ref10'];
// le format de chaque photo commandée (format1 pour la ref1, format2 pour la ref2, etc jusqu'à 10
        $format1    = $_POST['format1'];
   $format2    = $_POST['format2'];
   $format3    = $_POST['format3'];
   $format4    = $_POST['format4'];
   $format5    = $_POST['format5'];
   $format6    = $_POST['format6'];
   $format7    = $_POST['format7'];
   $format8    = $_POST['format8'];
   $format9    = $_POST['format9'];
   $format10   = $_POST['format10'];
// le nombre photo commandée pour chaque format (nombre1 pour la photo ref1 format1, etc.
   $nombre1    = $_POST['nombre1'];
   $nombre2    = $_POST['nombre2'];
   $nombre3    = $_POST['nombre3'];
   $nombre4    = $_POST['nombre4'];
   $nombre5    = $_POST['nombre5'];
   $nombre6    = $_POST['nombre6'];
   $nombre7    = $_POST['nombre7'];
   $nombre8    = $_POST['nombre8'];
   $nombre9    = $_POST['nombre9'];
   $nombre10   = $_POST['nombre10'];
// le prix de la ligne ref1, de la ligne ref2 etc. Problème: le visiteur doit faire l'addition lui même =  source d'erreur
   $prix1      = $_POST['prix1'];
   $prix2      = $_POST['prix2'];
   $prix3      = $_POST['prix3'];
   $prix4      = $_POST['prix4'];
   $prix5      = $_POST['prix5'];
   $prix6      = $_POST['prix6'];
   $prix7      = $_POST['prix7'];
   $prix8      = $_POST['prix8'];
   $prix9      = $_POST['prix9'];
   $prix10     = $_POST['prix10'];
   
   // trouver comment calculer le total de photos commandées $nombretotal  = nombre de ref1 + nombre de ref2 + nombre de ref3  etc.
   // trouver comment faire la liste de toutes les références des photos choisies $liste_ref = ref1, ref2, ref3, etc.
   // trouver comment faire la liste de tous les formats par photo choisie ??. Attention, deux photos peuvent
   // être en deux formats différents

    //Regex pour le traitement de l'email.
    $valid = "^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\.[a-z]{2,4}$";
   
// Vérification des champs vides ou invalides
    if ($prenom == '' || $nom == '' || $adresse == '' || $ville == '' || $code == '' || $pays == '' || $tel == '' || $email == '' || $ref1 == '' || $format1 == '' || $nombre1 == '' || $prix1 == '' || !(eregi($valid, $email)))

    {     // Message d'erreur affiché sur l'écran du visiteur
?>
<table width="515" border="1" align="center">
  <tr>
    <td width="172"><div align="center"><img src="/expe/graphics/logo_circle160_indexpage.jpg" alt="Expedition" width="160" height="160" /></div></td>
    <td width="327" class="form"><div align="center"><strong><font size="+1">Informations incomplètes</font></strong></div></td>
  </tr>
</table>
<div align="left"><span class="form"><strong><br />
  Un (ou plusieurs) champ(s) n'a(ont) pas été correctement rempli(s).</strong></span>
</div>
<ol>
  <?php
        if ($prenom == '')
        {
            print "<li>Vous n'avez pas précisé votre prénom</li>\n";
        }
        if ($nom == '')
        {
            print "<li>Vous n'avez pas précisé votre nom</li>\n";
        }
        if(!$email)
        {
            print "<li>Vous avez omis de mentionner une adresse email !</li>\n";
        }
        if(($email) && !(eregi($valid, $email))) //Si il y a une adresse inscrite mais invalide
       
        {
            print "<li>L'adresse électronique saisie est invalide.</li>\n";
        }
        if ($adresse == '') // Si le champ "adresse" est vide,
        {
            print "<li>Vous n'avez pas précisé votre adresse postale</li>\n";
        }
        if ($ville == '') // Si le champ "ville" est vide,
        {
            print "<li>Vous n'avez pas précisé votre ville</li>\n";
        }
        if ($code == '') // Si le champ "code" est vide,
        {
            print "<li>Vous n'avez pas précisé votre code postal</li>\n";
        }
        if ($pays == '') // Si le champ "pays" est vide,
        {
            print "<li>Vous n'avez pas précisé votre pays</li>\n";
        }
      if ($tel == '') // Si le champ "tel" est vide,
        {
            print "<li>Merci de préciser un numéro de téléphone</li>\n";
        }
      if ($ref1 == '') // Si le champ "reference" est vide,
        {
            print "<li>Vous n'avez pas précisé la référence de la photo</li>\n";
        }
      if ($format1 == '') // Si le champ "format" est vide,
        {
            print "<li>Vous n'avez pas précisé le format de la photo</li>\n";
        }
      if ($nombre1 == '') // Si le champ "nombre" est vide,
        {
            print "<li>Combien de photos voulez vous pour chaque format</li>\n";
        }

        //Si erreurs, affichage du formulaire contenant les données déjà saisies par l'utilisateur.
        //Si pas d'erreur, on continue
?>
</ol><form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<table summary="">
  <col width="250" title="titres" />
  <col width="15" title="oblige" />
  <col width="250" title="donnees" />
  <tr>
    <td class="form"><p>Mme, Mlle ou Mr :</p></td>
    <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold">*</div></td>
    <td class="form"><input type="text" name="genre" maxlength="40" class="cases" value="<?php echo $genre ?>" /></td>
  </tr>
  <tr>
    <td class="form"><p>Votre prénom:</p></td>
    <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold">*</div></td>
    <td class="form"><input type="text" name="prenom" maxlength="40" class="cases" value="<?php echo $prenom ?>" /></td>
  </tr>
  <tr>
    <td class="form"><p>Votre nom de famille:</p></td>
    <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold">*</div></td>
    <td class="form"><input type="text" name="nom" maxlength="40" class="cases" value="<?php echo $nom ?>" /></td>
  </tr>
 
  <tr>
    <td class="form"><p>Votre adresse postale:</p></td>
    <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold">*</div></td>
    <td class="form"><input type="text" name="adresse" maxlength="200" class="cases" value="<?php echo $adresse ?>" /></td>
  </tr>
  <tr>
    <td class="form"><p>Votre ville:</p></td>
    <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold">*</div></td>
    <td class="form"><input type="text" name="ville" maxlength="40" class="cases" value="<?php echo $ville ?>" /></td>
  </tr>
  <tr>
    <td class="form"><p>Votre code postal:</p></td>
    <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold">*</div></td>
    <td class="form"><input type="text" name="code" maxlength="40" class="cases" value="<?php echo $code ?>" /></td>
  </tr>
  <tr>
    <td class="form"><p>Votre pays:</p></td>
    <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold">*</div></td>
    <td class="form"><input type="text" name="pays" maxlength="40" class="cases" value="<?php echo $pays ?>" /></td>
  </tr>
  <tr>
    <td class="form"><p>Votre adresse email:</p></td>
    <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold">*</div></td>
    <td class="form"><input type="text" name="email" maxlength="40" class="cases" value="<?php echo $email ?>" /></td>
  </tr>
  <tr>
    <td class="form"><p>Votre t&eacute;l&eacute;phone:</p></td>
    <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold">*</div></td>
    <td class="form"><input type="text" name="tel" maxlength="12" class="cases" value="<?php echo $tel ?>" /></td>
  </tr>
  <tr>
    <td class="form">Vous avez command&eacute; : </td>
    <td class="form">&nbsp;</td>
    <td class="form"><input type="text" name="nombre1" maxlength="40" class="cases" value="<?php echo $nombre1 ?>" /> photos,</td>
  </tr>
  <tr>
    <td class="form">dont les r&eacute;f&eacute;rences sont:</td>
    <td class="form">&nbsp;</td>
    <td class="form"><input type="text" name="ref1" maxlength="40" class="cases" value="<?php echo $ref1 ?>" /></td>
  </tr>
  <tr>
    <td class="form">au format </td>
    <td class="form">&nbsp;</td>
    <td class="form"><input type="text" name="format1" maxlength="40" class="cases" value="<?php echo $format1 ?>" /></td>
  </tr>
  <tr>
    <td class="form">Le prix total de votre commande est de </td>
    <td class="form">&nbsp;</td>
    <td class="form"><input type="text" name="prix1" maxlength="40" class="cases" value="<?php echo $prix1 ?>" /></td>
  </tr>
  <tr>
    <td colspan="3"><div style="text-align:center;">
        <input type="submit" class="verif" name="envoi" value="Envoyer" />
        &nbsp;
        <input type="reset" class="verif" value="Recommencer" />
      </div></td>
  </tr>
</table>
<?php
    }
    else
    {   //si la commande doit être envoyée à un ami (et si tous les champs obligatoires sont remplis et valides:
        //on affiche le message des informations reçues
      
        if ($nom_ami == TRUE)
          {
           print "<h1>Merci ".$genre." ".$nom." . Voici les informations que vous avez fournies pour votre commande</h1>\n";
           print "Vous avez commandé : ".$nombretotal." photos dont les références sont:<br />\n";
           print "<p>".$liste_ref." <br />\n";
          print "Votre commande s'élève à : ".$prixl."<br />\n";
             print "<p>Vous souhaitez que ces photos soient envoyées à :</p>\n";
             print "<p>".$genreami." ".$prenom_ami." ".$nom_ami."<br />\n";
             print "Habitant à : ".$adresseami." ".$codeami." ".$villeami." ".$paysami." <br />\n";
           print "Nous vous confirmerons l'envoi de votre commande par courrier électronique à: <a href=\"mailto:".$email."\">".$email."</a><br />\n";
          }
         else  //l'envoi doit être fait directement à la personne qui commande, donc affichage du message final des informations reçues
          {
             print "<h1>Merci ".$genre." ".$nom." . Voici les informations que vous avez fournies pour votre commande</h1>\n";
           print "Vous avez commandé : ".$nombretotal." photos dont les références sont:<br />\n";
           print "<p>".$liste_ref." <br />\n";
          print "Votre commande s'élève à : ".$prixl."<br />\n";
             print "<p>Vous souhaitez que ces photos soient envoyées à votre adresse:</p>\n";
             print "<p>".$adresse." ".$code." ".$ville." ".$pays." </p><br />\n";
           print "<p>Nous vous confirmerons l'envoi de votre commande par courrier électronique à: <a href=\"mailto:".$email."\">".$email."</a></p><br />\n";
          }

        //Envoi de ces mêmes informations par courrier électronique : 
      if ($nom_ami == '') //la commande est pour le visiteur
      {
          $message  = "<p>Une commande de photos vient d'être passée par :<br>\r\n";
        $message .= "<p>".$genre." ".$prenom." ".$nom."</p><br />\r\n";
        $message .= "<p>".$adresse."</p><br />\r\n";
        $message .= "<p>".$code." ".$ville." ".$pays."</p><br />\r\n";
        $message .= "La commande consiste en : ".$nombretotal." photos au format ".$tousformats." dont les références sont ".$liste_ref."  </p><br />\r\n";
        $message .= "Confirmer la commande par courriel à: <a href=\"mailto:".$email."\">".$email."</a></p><br />\r\n";
      
      }
      else //le champ nom_ami est renseigné, l'envoi doit donc partir vers une tierce personne
      {
        $message  = "<p>Une commande de photos vient d'être passée par ".$genre." ".$prenom." ".$nom.":<br>\r\n";
        $message .= "<p>pour ".$genreami." ".$prenom_ami." ".$nom_ami."</p><br />\r\n";
        $message .= "<p>".$adresseami."</p><br />\r\n";
        $message .= "<p>".$codeami." ".$villeami." ".$paysami."</p><br />\r\n";
        $message .= "<p>Le montant calculé de la commande s'élève à : ".$prixl."<br />\n";
        $message .= "Confirmer la commande par courriel à: <a href=\"mailto:".$email."\">".$email."</a></p><br />\r\n";
      }
      
        //On envoie le message
        if(mail($email_dest, $subject, $message, $headers))
        {
           echo("<h3>Commande de photos reçue</h3>\n");
           echo("<p><h3>Votre commande a bien été prise en compte et est en cours de traitement.</h3></p>");
        }
        else
        {
            echo("<p><h3>Un incident technique s'est produit, Nous n'avons pas reçu votre commande. Contactez nous directement à <a href=mailto:alain@addawebdesign.com</a></h3></p>\n");
        }
    }
    print("<p>Retour vers le formulaire: cliquer <a href=\"/expe/commandephoto.php\" title=\"Retour vers le le bon de commande\">ICI</a>. Sinon <a href=\"javascript: window.close()\">Fermer
      cette fen&ecirc;tre - Close this window</a> </p>");
}
//Si cette page s'ouvre pour la première fois on affiche le formulaire normalement
else
{
?>
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
  <table width="750" align="center">
<tr>
<td><table width="750" border="1" align="center" cellpadding="0" cellspacing="3">
    <tr>
      <td width="50%" class="form"><strong>Mes coordonn&eacute;es sont :</strong></td>
      <td width="50%" class="form"><strong>Je fais cet achat en vue de faire
      un cadeau, <br />
      merci d&rsquo;envoyer les photos directement &agrave; :</strong></td>
    </tr>
    <tr>
      <td class="form"><table width="100%" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td class="form"><p>Genre (Mme, Mlle, Mr) </p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="genre" maxlength="4" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Pr&eacute;nom </p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="prenom" maxlength="40" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Nom de famille </p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="nom" maxlength="40" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Adresse postale</p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="adresse" maxlength="200" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Ville</p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="ville" maxlength="40" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Code postal</p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="code" maxlength="40" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Pays </p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="pays" maxlength="40" class="black" value="" /></td>
        </tr>
        <tr>
          <td valign="middle" class="form">Num&eacute;ro de t&eacute;l&eacute;phone </td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td valign="middle" class="form"><input type="text" name="tel" maxlength="18" class="black" value="" /></td>
        </tr>
        <tr>
          <td valign="middle" class="form"><p>Adresse email </p></td>
          <!-- Et du texte libre. -->
          <td class="form">&nbsp;</td>
          <td valign="middle" class="form"><input type="text" name="email" maxlength="40" class="black" value="" /></td>
        </tr>
       
      </table></td>
      <td class="form"><table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td class="form"><p>Genre (Mme, Mlle, Mr) </p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="genreami" maxlength="4" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Pr&eacute;nom </p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="prenom_ami" maxlength="40" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Nom de famille </p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="nom_ami" maxlength="40" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Adresse postale</p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="adresseami" maxlength="200" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Ville</p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="villeami" maxlength="40" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Code postal</p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="codeami" maxlength="40" class="black" value="" /></td>
        </tr>
        <tr>
          <td class="form"><p>Pays </p></td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td class="form"><input type="text" name="paysami" maxlength="40" class="black" value="" /></td>
        </tr>
        <tr>
          <td valign="middle" class="form">Num&eacute;ro de t&eacute;l&eacute;phone </td>
          <td class="form"><div style="color: #ff0000; text-align: center; font-weight: bold"><font size="+1">*</font></div></td>
          <td valign="middle" class="form"><input type="text" name="telami" maxlength="18" class="black" value="" /></td>
        </tr>
        <tr>
          <td valign="middle" class="form"><p>Adresse email </p></td>
          <!-- Et du texte libre. -->
          <td class="form">&nbsp;</td>
          <td valign="middle" class="form"><input type="text" name="emailami" maxlength="40" class="black" value="" /></td>
        </tr>
       
      </table></td>
    </tr>
  </table>
  <table width="100%" align="center" cellspacing="0" summary="">
    <col width="300" title="titres" />
    <col width="15" title="oblige" />
    <col width="285" title="donnees" />
   
    <tr valign="middle">
      <td width="90%" height="58" colspan="3" class="form"><table width="100%" cellspacing="0" cellpadding="0">
       
        <tr>
          <td colspan="8" class="form">&nbsp;</td>
        </tr>
        <tr>
          <td colspan="8" class="form"><strong>D&eacute;tails de votre commande
              : </strong></td>
          </tr>
        <tr>
          <td class="form">Photo R&eacute;f.   </td>
          <td width="10%" class="form"><input type="text" name="ref1" maxlength="3" class="black" value="" /></td>
          <td class="form"><div align="center">Format</div></td>
          <td class="form"><select name = "format1">
            <option value = "30x45" selected="selected">30x45 (55€)</option>
            <option value = "40x60">40x60 (70€)</option>
            <option value = "50x75">50x75 (80€)</option>
            <option value = "60x90">60x90 (100€)</option>
            <option value = "76x120">76x120 (150€)</option>
                    </select></td>
          <td width="12%" class="form"><div align="center">Nombre</div></td>
          <td class="form"><select name = "nombre1">
            <option value = "1">1</option>
            <option value = "2">2</option>
            <option value = "3">3</option>
            <option value = "4">4</option>
            <option value = "5">5</option>
          </select></td>
          <td class="form"><div align="center">Prix</div></td>
          <td width="10%" class="form"><input type="text" name="prix1" /></td>
        </tr>
        <tr>
          <td class="form">Photo R&eacute;f.   </td>
          <td width="10%" class="form"><input type="text" name="ref2" maxlength="3" class="black" value="" /></td>
          <td class="form"><div align="center">Format</div></td>
          <td class="form"><select name = "format2">
            <option value = "30x45" selected="selected">30x45 (55&euro;)</option>
            <option value = "40x60">40x60 (70&euro;)</option>
            <option value = "50x75">50x75 (80&euro;)</option>
            <option value = "60x90">60x90 (100&euro;)</option>
            <option value = "76x120">76x120 (150&euro;)</option>
                    </select></td>
          <td class="form"><div align="center">Nombre</div></td>
          <td class="form"><select name = "nombre2">
            <option value = "1">1</option>
            <option value = "2">2</option>
            <option value = "3">3</option>
            <option value = "4">4</option>
            <option value = "5">5</option>
          </select></td>
          <td class="form"><div align="center">Prix</div></td>
          <td class="form"><input type="text" name="prix2" /></td>
        </tr>
        <tr>
          <td class="form">Photo R&eacute;f.   </td>
          <td width="10%" class="form"><input type="text" name="ref3" maxlength="3" class="black" value="" /></td>
          <td class="form"><div align="center">Format</div></td>
          <td class="form"><select name = "format3">
            <option value = "30x45" selected="selected">30x45 (55&euro;)</option>
            <option value = "40x60">40x60 (70&euro;)</option>
            <option value = "50x75">50x75 (80&euro;)</option>
            <option value = "60x90">60x90 (100&euro;)</option>
            <option value = "76x120">76x120 (150&euro;)</option>
                    </select></td>
          <td class="form"><div align="center">Nombre</div></td>
          <td class="form"><select name = "nombre3">
            <option value = "1">1</option>
            <option value = "2">2</option>
            <option value = "3">3</option>
            <option value = "4">4</option>
            <option value = "5">5</option>
          </select></td>
          <td class="form"><div align="center">Prix</div></td>
          <td class="form"><input type="text" name="prix3" /></td>
        </tr>
        <tr>
          <td class="form">Photo R&eacute;f.   </td>
          <td width="10%" class="form"><input type="text" name="ref4" maxlength="3" class="black" value="" /></td>
          <td class="form"><div align="center">Format</div></td>
          <td class="form"><select name = "format4">
            <option value = "30x45" selected="selected">30x45 (55&euro;)</option>
            <option value = "40x60">40x60 (70&euro;)</option>
            <option value = "50x75">50x75 (80&euro;)</option>
            <option value = "60x90">60x90 (100&euro;)</option>
            <option value = "76x120">76x120 (150&euro;)</option>
                    </select></td>
          <td class="form"><div align="center">Nombre</div></td>
          <td class="form"><select name = "nombre4">
            <option value = "1">1</option>
            <option value = "2">2</option>
            <option value = "3">3</option>
            <option value = "4">4</option>
            <option value = "5">5</option>
          </select></td>
          <td class="form"><div align="center">Prix</div></td>
          <td class="form"><input type="text" name="prix4" /></td>
        </tr>
        <tr>
          <td class="form">Photo R&eacute;f.   </td>
          <td width="10%" class="form"><input type="text" name="ref5" maxlength="3" class="black" value="" /></td>
          <td class="form"><div align="center">Format</div></td>
          <td class="form"><select name = "format5">
            <option value = "30x45" selected="selected">30x45 (55&euro;)</option>
            <option value = "40x60">40x60 (70&euro;)</option>
            <option value = "50x75">50x75 (80&euro;)</option>
            <option value = "60x90">60x90 (100&euro;)</option>
            <option value = "76x120">76x120 (150&euro;)</option>
                    </select></td>
          <td class="form"><div align="center">Nombre</div></td>
          <td class="form"><select name = "nombre5">
            <option value = "1">1</option>
            <option value = "2">2</option>
            <option value = "3">3</option>
            <option value = "4">4</option>
            <option value = "5">5</option>
          </select></td>
          <td class="form"><div align="center">Prix</div></td>
          <td class="form"><input type="text" name="prix5" /></td>
        </tr>
        <tr>
          <td class="form">Photo R&eacute;f.   </td>
          <td width="10%" class="form"><input type="text" name="ref6" maxlength="3" class="black" value="" /></td>
          <td class="form"><div align="center">Format</div></td>
          <td class="form"><select name = "format6">
            <option value = "30x45" selected="selected">30x45 (55&euro;)</option>
            <option value = "40x60">40x60 (70&euro;)</option>
            <option value = "50x75">50x75 (80&euro;)</option>
            <option value = "60x90">60x90 (100&euro;)</option>
            <option value = "76x120">76x120 (150&euro;)</option>
                    </select></td>
          <td class="form"><div align="center">Nombre</div></td>
          <td class="form"><select name = "nombre6">
            <option value = "1">1</option>
            <option value = "2">2</option>
            <option value = "3">3</option>
            <option value = "4">4</option>
            <option value = "5">5</option>
          </select></td>
          <td class="form"><div align="center">Prix</div></td>
          <td class="form"><input type="text" name="prix6" /></td>
        </tr>
        <tr>
          <td class="form">Photo R&eacute;f.   </td>
          <td width="10%" class="form"><input type="text" name="ref7" maxlength="3" class="black" value="" /></td>
          <td class="form"><div align="center">Format</div></td>
          <td class="form"><select name = "format7">
            <option value = "30x45" selected="selected">30x45 (55&euro;)</option>
            <option value = "40x60">40x60 (70&euro;)</option>
            <option value = "50x75">50x75 (80&euro;)</option>
            <option value = "60x90">60x90 (100&euro;)</option>
            <option value = "76x120">76x120 (150&euro;)</option>
                    </select></td>
          <td class="form"><div align="center">Nombre</div></td>
          <td class="form"><select name = "nombre7">
            <option value = "1">1</option>
            <option value = "2">2</option>
            <option value = "3">3</option>
            <option value = "4">4</option>
            <option value = "5">5</option>
          </select></td>
          <td class="form"><div align="center">Prix</div></td>
          <td class="form"><input type="text" name="prix7" /></td>
        </tr>
        <tr>
          <td class="form">Photo R&eacute;f.  </td>
          <td width="10%" class="form"><input type="text" name="ref8" maxlength="3" class="black" value="" /></td>
          <td class="form"><div align="center">Format</div></td>
          <td class="form"><select name = "format8">
            <option value = "30x45" selected="selected">30x45 (55&euro;)</option>
            <option value = "40x60">40x60 (70&euro;)</option>
            <option value = "50x75">50x75 (80&euro;)</option>
            <option value = "60x90">60x90 (100&euro;)</option>
            <option value = "76x120">76x120 (150&euro;)</option>
                    </select></td>
          <td class="form"><div align="center">Nombre</div></td>
          <td class="form"><select name = "nombre8">
            <option value = "1">1</option>
            <option value = "2">2</option>
            <option value = "3">3</option>
            <option value = "4">4</option>
            <option value = "5">5</option>
          </select></td>
          <td class="form"><div align="center">Prix</div></td>
          <td class="form"><input type="text" name="prix8" /></td>
        </tr>
        <tr>
          <td class="form">Photo R&eacute;f.   </td>
          <td width="10%" class="form"><input type="text" name="ref9" maxlength="3" class="black" value="" /></td>
          <td class="form"><div align="center">Format</div></td>
          <td class="form"><select name = "format9">
            <option value = "30x45" selected="selected">30x45 (55&euro;)</option>
            <option value = "40x60">40x60 (70&euro;)</option>
            <option value = "50x75">50x75 (80&euro;)</option>
            <option value = "60x90">60x90 (100&euro;)</option>
            <option value = "76x120">76x120 (150&euro;)</option>
                    </select></td>
          <td class="form"><div align="center">Nombre</div></td>
          <td class="form"><select name = "nombre9">
            <option value = "1">1</option>
            <option value = "2">2</option>
            <option value = "3">3</option>
            <option value = "4">4</option>
            <option value = "5">5</option>
          </select></td>
          <td class="form"><div align="center">Prix</div></td>
          <td class="form"><input type="text" name="prix9" /></td>
        </tr>
        <tr>
          <td class="form">Photo R&eacute;f.  </td>
          <td width="10%" class="form"><input type="text" name="ref10" maxlength="3" class="black" value="" /></td>
          <td class="form"><div align="center">Format</div></td>
          <td class="form"><select name = "format10">
            <option value = "30x45" selected="selected">30x45 (55&euro;)</option>
            <option value = "40x60">40x60 (70&euro;)</option>
            <option value = "50x75">50x75 (80&euro;)</option>
            <option value = "60x90">60x90 (100&euro;)</option>
            <option value = "76x120">76x120 (150&euro;)</option>
                    </select></td>
          <td class="form"><div align="center">Nombre</div></td>
          <td class="form"><select name = "nombre10">
            <option value = "1">1</option>
            <option value = "2">2</option>
            <option value = "3">3</option>
            <option value = "4">4</option>
            <option value = "5">5</option>
          </select></td>
          <td class="form"><div align="center">Prix</div></td>
          <td class="form"><input type="text" name="prix10" /></td>
        </tr>
        <tr>
          <td class="form">&nbsp;</td>
          <td width="10%" class="form">&nbsp;</td>
          <td colspan="2" class="form">&nbsp;</td>
          <td colspan="2" class="form">&nbsp;</td>
          <td class="form"><strong>Total</strong></td>
          <td class="form">&nbsp;</td>
        </tr>
      </table>       
      </td>
    </tr>
    <tr valign="middle">
      <td height="8" colspan="3" class="form"><div align="center"><img src="/images/gif/500_by_1_blue.gif" width="500" height="1" /></div></td>
    </tr>
    <tr>
      <td colspan="3"><div style="text-align:center;">
          <input type="submit" class="verif" name="envoi" value="Envoyer" />
          &nbsp;
          <input type="reset" class="verif" value="Recommencer" />
        </div></td>
    </tr>
  </table>
  </td></tr></table>
</form>

<?php
}
?>
</body>
</html>


Voilà... Merci d'avoir parcouru ce code jusqu'au bout!!

Vous trouverez certainement où sont les erreurs, moi je patauge, le gilet de sauvetage a été percuté!!
A.
 
aventvoy Visiter le site web du posteur
rog
WRInaute accro
WRInaute accro

Inscrit le: 21 Sep 2006
Messages: 1662
Localisation: sapucaia do sul (RS)

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 10:38    Sujet du message: Bon de commande

et en plus les formats sont au même prix pour toutes les photos

il faut traiter les champs en tableau ex :

Code:
 <td class="form"><select name = "format1">


deviendrait

Code:
 <td class="form"><select name = "format[0]">


et ce pour tous les champs, avec une option supplementaire ici

Citation:
"><select name = "nombre[0]">
<option "selected" value = "0">commander</option>
<option value = "1">1</option>
<option value = "2">2</option>
<option value = "3">3</option>
<option value = "4">4</option>
<option value = "5">5</option>
</select>


après il n'y a plus qu'à faire une boucle pour calculer les lignes
et surtout on en fait une pour afficher les menus en html

et il serait important que le client connaisse deja le montant de sa commande par un javascript avant de valider le formulaire

rog
 
rog Visiter le site web du posteur
Marie-Aude
WRInaute accro
WRInaute accro

Inscrit le: 05 Juin 2006
Messages: 3443
Localisation: More than a plastic girl

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 10:46    Sujet du message: Bon de commande

Je ne connais pas la syntaxe, mais je vais te le faire en "résumé"....

Récupérer nombre de lignes de commandes, ncde
n=0
valeur commande = 0

Do while n<= ncde
Récupérer photo
Récupérer quantité
Récupérer format
Récupérer tarif
valeur commande = valeur commande + (quantité * tarif)
n=n+1
End
 
Marie-Aude Visiter le site web du posteur
bidulemachin
WRInaute discret
WRInaute discret

Inscrit le: 05 Oct 2007
Messages: 68

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 16:15    Sujet du message: Bon de commande

Je suis désolé il est 16h et je fatigue déjà.

Essaye déjà ca pour alléger ton code :

Code:


foreach ($_POST as $name => $valeur )
{
    $name = $valeur;
}



De cette manière toutes tes valeurs POST sont converties en variable et ca allège considérablement ton code.
Ensuite, essaye :

Code:


for($i=0; $i <10; ++$i)
{
$format = "format".$i;
$photo = "photo".$i;
$tarif = "tarif".$i;
$total = "total".$i;

$$total = $$format + $$photo + $$tarif;

}


Tu as ensuite des variables du type total1, total2...
 
bidulemachin Visiter le site web du posteur
herveG
Modérateur
Modérateur

Inscrit le: 05 Mar 2003
Messages: 8314
Localisation: Allemagne

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 16:47    Sujet du message: Bon de commande

Eh maintenant que tu as bien réfléchi a tout ca, tu connais la gestion de panier paypal ? Qui te permet de réaliser des boutons tout simples que tu places ou tu vexu dans tes pages ? un bouton "ajouter au panier" et un bouton "voir mon panier" super flexible. C est hors sujet mais si ca peut correspondre a ce que tu cherches...
 
herveG Visiter le site web du posteur
aventvoy
WRInaute occasionnel
WRInaute occasionnel

Inscrit le: 17 Nov 2004
Messages: 169
Localisation: Canada

URL permanente de ce messagePosté le : Jeu Déc 06, 2007 20:08    Sujet du message: Bon de commande

Merci à tous!
Vous aurez compris que je débute en PHP, c'est laborieux...
Je vais essayer de me débrouiller avec vos explications et mes bouquins.
J'aurai certainement encore des questions... A demain donc! Smile
 
aventvoy Visiter le site web du posteur
aventvoy
WRInaute occasionnel
WRInaute occasionnel

Inscrit le: 17 Nov 2004
Messages: 169
Localisation: Canada

URL permanente de ce messagePosté le : Ven Déc 07, 2007 1:25    Sujet du message: Bon de commande

Bom dia Rog,
Je comprends pas...
Comme j'ai 4 formats, faut bien que je définisse chaque format pour le récupérer après, donc faudrait que je fasse un array genre
Code:

$ref = [] //il y a 50 photos
$format = array("30x45", "40x60", "50x75", "60x90", "76x120")
et idem pour la quantité
$nombre = array("1", "2", "3", "4", "5")


Mais alors dans ce cas, mes variables $format = $_POST['format']; et $nombre = $_POST['nombre']; ne marchent plus vu que j'ai ensemble deux égalités différentes...
Code:

$ref        = $_POST['ref'];
$format     = array("30x45", "40x60", "50x75", "60x90", "76x120");
$format     = $_POST['format'];
$nombre     = array("1", "2", "3", "4", "5");
$nombre     = $_POST['nombre'];
$prix       = $_POST['prix'];


Dans le message que je reçois, j'ai
Citation:
La commande consiste en : Array photos références 028 au format Array

(j'avais demandé 2 photos ref. 028 au format 40x60...)

Avec une seule photo, 4 formats possibles, le nombre qu'on en veut, et sans calcul de tarif, c'est tout bon (facile:? )
Plus ça va moins je comprends...
 
aventvoy Visiter le site web du posteur
rog
WRInaute accro
WRInaute accro

Inscrit le: 21 Sep 2006
Messages: 1662
Localisation: sapucaia do sul (RS)

URL permanente de ce messagePosté le : Ven Déc 07, 2007 4:41    Sujet du message: Bon de commande

ça c'est parce que tu utilises la formule de machin bidulle qui ne doit pas figurer dans ton livre

en general je ne poste pas de code, je vais faire une exception

1) le html
Code:

$display = NULL;   #   pas confiance dans les lib ob
# declaration parfaite
$ref = [] //il y a 50 photos
$format = array(0=>"30x45", "40x60", "50x75", "60x90", "76x120");
$tarif = array(0=>55,60,70,80,100);
$nombre = array(0=>"commander","1", "2", "3", "4", "5");
$qte = array_flip($nombre);


#    on affiche le html
for($i = 0; $i < count($ref); $i++)
   {
   
   $display .= '<tr>
               <td>
                  "<input type="text" name = "ref['.$i.']"> maxlength="3" class="black" value="'.$ref[$i].'" />
               </td>';
               
   $display .= '
               <td>
                  <select name = "format['.$i.']">';
         
         for($j = 0; $j < count($format); $j++)
            {
            $display .= '<option value = "'.$tarif[$j].'">'.$format[$j]."</option>\n";
            }
                  
   $display .= '      </select>
               </td>
               <td>
                  <select name = "nombre['.$i.']">';
         for($j = 0; $j < count($nombre); $j++)
            {
            $display .= '<option value = "'.$qte[$j].'">'.$nombre[$j]."</option>\n";
            }
   $display .= '      </select>
               </td>
            </tr>';
   }


la recuperation
Code:

##############################################################
# recuperation attention il faut sanitizer les user input
##############################################################
$sum = 0:
#
for($i = 0; $i < count($_POST['ref']); $i++)
   {
   $sum += $_POST['format'][$i] * $_POST['nombre'][$i];
                }


rog
 
rog Visiter le site web du posteur
aventvoy
WRInaute occasionnel
WRInaute occasionnel

Inscrit le: 17 Nov 2004
Messages: 169
Localisation: Canada

URL permanente de ce messagePosté le : Ven Déc 07, 2007 5:29    Sujet du message: Bon de commande

Merci beaucoup pour l'exception Rog!
Je vais reprendre ça demain matin, là j'ai les yeux qui n'en peuvent plus (et le neurone non plus...).
Quand tu dis qu'il faut "sanitizer" les "user input" tu veux dire qu'il faut s'assurer qu'il n'y a pas de lettres là ou on attend un chiffre (dans ce cas utilisation de regex etc.), ou tu veux parler de sécurité genre entrée de code, de script ou autre? Dans ce cas il faut utiliser strip_tags, ou htmlspecialchars, ou autre chose?
Merci encore,
A.
 
aventvoy Visiter le site web du posteur