Ce forum est maintenant fermé, seule cette archive statique reste consultable.
  FORUM Rue-Montgallet.com
  Programmation
  Php - Sql

  Pasage variable d'une page à l'autre

Bas de page
Auteur Sujet :

Pasage variable d'une page à l'autre

n°12689
Steffane
Profil : Jeune recrue
Posté le 21-04-2005 à 16:30:17  
 

Bonjour
 
Depuis register_global à off je suis en galère !
 
J'ai une petite boutique en ligne et le caddie ne se remplit plus !
 
J'ai ma page detail.php avec le detail de l'article (nom, référence, prix, taille(si besoin) couleur(si besoin) etc ...) le tout dans un <form action="commande.php" method="post">
Une fois cliqué sur "ajouter au caddie" on passe par une page commande.php qui ouvre une session:  
 

Code :
  1. <?
  2. session_start();
  3. session_register("new_list" );
  4. if(!isset($taille)){$taille="";} else {$taille="#!#!#".$taille;}
  5. if(!isset($couleur)){$couleur="";} else {$couleur="#!#!#".$couleur;}
  6. if(!isset($cote)){$cote="";} else {$cote="#!#!#".$cote;}
  7. if(!isset($flex)){$flex="";} else {$flex="#!#!#".$flex;}
  8. $new_list[$id.$taille.$couleur.$cote.$flex]=$amount;
  9. ?>
  10. <script language="javascript">
  11. document.location='<? echo "caddie.php"; ?>';
  12. </script>


 
Et on fini sur la page caddie
 

Code :
  1. <?
  2. if (!session_is_registered('new_list')) {
  3. echo "<br><br><center><font size=2 color=red><b>Vous n'avez pas de produits dans votre caddie!</font></center><br><br>";
  4. } else {
  5. if (count($new_list) == "0" || !is_array($new_list) || !isset($new_list)) {
  6.  echo  "<br><br><center><font size=2 color=red><b>Vous n'avez pas de produits dans votre caddie!</font></center><br><br>";
  7. } else {
  8. echo "<p align=center><font size=2><b>Votre Caddie contient</b></font><hr align=center size=1 color=#333399 width=165>";
  9.  echo "<table border=\"0\" width=\"95%\" cellspacing=\"1\" cellpadding=\"2\" align=\"center\">";
  10.  echo "<tr bgcolor=#333399>";
  11. echo "<td><center><font size=1 color=#E9EEF5><b>Articles</b></font></center></td>";
  12. echo "<td><center><font size=1 color=#E9EEF5><b>Qte</b></font></center></td>";
  13. echo "<td><center><font size=1 color=#E9EEF5><b>Total HT</b></font></center></td>";
  14. echo "<td><center><font size=1 color=#E9EEF5><b>Total TTC</b></font></center></td>";
  15. echo "<td><center><font size=1 color=#E9EEF5><b>Vider</b></font></center></td>";
  16.  reset ($new_list);
  17.  while (list ($key, $val) = each ($new_list)) {
  18.   $key_temp=explode("#!#!#",$key);
  19.       $id_temp=$key_temp[0];
  20.       if(isset($key_temp[1])){$taille_temp=$key_temp[1];} else {$taille_temp="";}
  21.       if(isset($key_temp[2])){$couleur_temp=$key_temp[2];} else {$couleur_temp="";}
  22.   if(isset($key_temp[3])){$cote_temp=$key_temp[3];} else {$cote_temp="";}
  23.   if(isset($key_temp[4])){$flex_temp=$key_temp[4];} else {$flex_temp="";}
  24.       $amount_temp=$val;
  25.             $id_temp=$_REQUEST[id];
  26.   $query = mysql_query("SELECT nom,prix,frais FROM $sbbproduit WHERE id='$id_temp'" );
  27.   $row = mysql_fetch_row($query);
  28.   echo "<tr>";
  29.   echo "<td class='centre2'><center><b>$row[0]";
  30.   if(isset($taille_temp!="" )){echo "<br>Taille : $taille_temp";}
  31.   if(isset($couleur_temp!="" )){echo "<br>Couleur : $couleur_temp";}
  32.   if(isset($cote_temp!="" )){echo "<br>Cot&eacute; : $cote_temp";}
  33.   if(isset($flex_temp!="" )){echo "<br>Courbe/Flex : $flex_temp";}
  34.   echo "</b></center></td>";
  35.                
  36.   echo "
  37.     <td align=center class=centre2>
  38.       <form action='quantite.php' method='post'>
  39. <input type='hidden' value='$key' name='key'>
  40. <input type='text' size='1' name='amount' value='$amount_temp'><input type='submit' value='ok'></td></form>";
  41.   $frais = $row[2];
  42.   $fraisht = $frais/$tva;
  43.   $frais_texte="Frais offert si total TTC > 450 $devises";
  44.             $fraisx = $frais ;
  45.   $fraisx1 = sprintf("%0.2f", $fraisx);
  46.   // $price = ($row[1] + $row[2]) * $amount_temp ;
  47.   $price = $row[1] * $amount_temp ;
  48.   $price = sprintf("%0.2f", $price);
  49.             $prixht = $price / $tva;
  50.             $prixht2 = sprintf("%0.2f", $prixht);
  51.   // $totalgeneral1 = ($price + $row[2]);
  52.   $totalgeneral1 = $price;
  53.   $prixunit = $row[1];
  54.   $prixunit = sprintf("%0.2f", $prixunit);
  55.   //echo "<td align=\"center\"><font size=1><b>$prixunit</b></font></td>";
  56.   // echo "<td align=\"center\"><font size=1><b>$fraisx1</b></font></td>";
  57.   echo "<td align=\"center\" class=\"centre2\"><b>$prixht2</b></td>";
  58.                   echo "<td align=\"center\" class=\"centre2\"><b>$price</b></td>";
  59. echo "<td align=\"center\" class=\"centre2\"><a href='delete.php?key=".rawurlencode($key)."'><font color='red'><b>OUI !</b></font></a></td>";
  60.   //echo "<td class=\"standard\"><font size=1>$devises</font></td>";
  61.   echo '</tr><tr><td colspan="5" height="1px" color="#339933"><hr height="1px" color="#339933"></td></tr>';
  62.   if (!IsSet($total)) {
  63.    $total = 0;
  64.   }
  65.   $total = $total + $price;
  66.   $totalht = $total / $tva;
  67.            
  68.  }
  69.  if($total>=450){
  70.   $frais="0";
  71.   $fraisht="0";
  72.   $frais_texte="Frais offert car total TTC > 450 $devises";
  73.  }
  74.  $total=$total+$frais;
  75.  $total = sprintf("%0.2f", $total);
  76.  $totalht=$totalht+$fraisht;
  77.  $totalht2 = sprintf("%0.2f", $totalht);
  78.  echo '
  79.   <tr>
  80.    <td align="center" colspan="2" class="centre2"><b>'.$frais_texte.'</b></td>
  81.    <td align="center" class="centre2"><b>'.sprintf("%0.2f", $fraisht).'</b></td>
  82.    <td align="center" class="centre2"><b>'.sprintf("%0.2f", $frais).'</b></td>
  83.    <td class="centre2">&nbsp;</td>
  84.   </tr>
  85.  ';
  86.  echo "</tr><tr bgcolor=#333399>";
  87.  echo "<td align=\"center\"><center><form action=\"confirme.php\" method=\"post\"><input type=\"submit\" value=\" COMMANDER \" class=\"input\"></td>";
  88.  echo "<td align=\"right\">&nbsp;</td>";
  89.             //echo "<td align=\"right\">&nbsp;</td>";
  90.  echo "<td align=\"center\"><font size=1 color=#E9EEF5><b>$totalht2</b></font></td>";
  91.             echo "<td align=\"center\"><font size=1 color=#E9EEF5><b>$total</b></font></td>";
  92.        echo "<td align=\"center\"><font size=1 color=#E9EEF5><b>$devises</b></font></td>";
  93.  echo "</tr><tr>";
  94.  echo "</tr></tr></table></form>";
  95. }
  96. }
  97. ?>


 
Quelles sont les variables à faire passer de la page detail.php à commande.php et de commande.php à caddie.php en sachant que c'est une session (ou un cookies ?!)  
 
D'une page à l'aure c'est facile .. $id=$_REQUEST[id]; ou $login=$_POST[login];
 
La j'avoue que je suis perdu ! :cry:  :pt1cable:


---------------
Merci Beaucoup
 
Steff
mood
Pub
Posté le 21-04-2005 à 16:30:17  
 

n°12696
Nodashi
Silence je dors
Profil : Dinosaure
Posté le 22-04-2005 à 00:11:42  
 

Bah ca depend de ton formulaire :p


---------------
informatique / jeu vidéo
n°12697
Steffane
Profil : Jeune recrue
Posté le 22-04-2005 à 03:58:46  
 

Voici donc le formulaire :
 
                     

Code :
  1. <?
  2.       
  3.        if ($row[7] != "nul" ) {
  4.  $split = explode("../", $row[7]);
  5.  $row[7] = $split[1];
  6.  $img = "<a href=\"javascript:AfficherImage('http://www.boutique.com/images/$row[16]')\" ><img src=\"$row[7]\" border=\"0\" alt=\"Cliquez pour agrandir\">";
  7.             $image2 = "<a href=\"javascript:AfficherImage('http://www.boutique.com/images/$row[16]')\" BORDER=\"0\"><img src=\"images/zoom.gif\" border=\"0\" align=\"center\" alt=\"Cliquez pour agrandir\"></a><br>";
  8. } else {
  9.  $img = "<img src=\"$images/na.jpg\" width=100 border=0>";
  10. }
  11. echo "<div align='center'>$img</a><br><br>$image2</div>";
  12. ?>
  13.                                       </td>
  14.                                       <td width="50%" align="center" class="td_texte"><?   $price = $row[4];
  15.   $price = sprintf("%0.2f", $price);
  16.   $totalgeneral1 = ($price + $fraisproduit2);
  17.                   $totalgeneral2 =  sprintf("%0.2f", $totalgeneral1);
  18.                    
  19.   // $prixht = $totalgeneral1 / $tva;
  20.   $prixht = $price / $tva;
  21.             $prixht2 = sprintf("%0.2f", $prixht);
  22.   $prixfr = $price * 6.56;
  23.    $referenceu = $row[5];
  24. ?>
  25.                                           <center>
  26.                                             <img src="images/prix.gif"> <br>
  27.                                             R&eacute;f&eacute;rence : <? echo "$row[5]"; ?><br>
  28.                       Prix magasin : <? echo "$row[13]"; ?> <? echo "$devises"; ?><br>
  29.                       <hr width="100" size="1" color="FFCC00">
  30.                       <b> Prix Web TTC : <? echo sprintf("%0.2f", $row[4]);
  31.      echo " &nbsp; $devises";
  32.       ?></b> <br>
  33.                       Prix Web HT : <? echo "$prixht2"; ?> <? echo "$devises"; ?><br>
  34.                       Soit : <? echo "$prixfr"; ?> F TTC <br>
  35.                       <br>
  36.                       <INPUT name="image" TYPE=image SRC="images/commander.gif" alt="Ajouter au caddie" BORDER="0">
  37.                       <br>
  38.                                         </center></td>
  39.                                     </tr>
  40.                                 </table></td>
  41.                               </tr>
  42.                               <tr bgcolor="#770B0B">
  43.                                 <td><b><font size="1"></font></b></td>
  44.                                 <td><b></b></td>
  45.                               </tr>
  46.                               <?
  47.                      
  48.                        $liste_taille=$row[11];
  49.                        if(strlen($liste_taille)!="0" ){
  50.                        $liste_taille=explode(" - ",$liste_taille);
  51.                      
  52.                        For($t=0;$t<count($liste_taille);$t++){
  53.                         $liste_deroulante_taille.='<option value="'.$liste_taille[$t].'">'.$liste_taille[$t].'</option>';
  54.                        }
  55.       if(isset($liste_deroulante_taille)){
  56.        echo '
  57.                         <tr>
  58.                           <td align="right" bgcolor="#770B0B" height="25"><b><font color="#FFCC00" size="1">TAILLES
  59.                             :&nbsp;&nbsp;&nbsp;</font></b></td>
  60.                           <td class="texte">
  61.                          <select name="taille" id="taille" size="1">
  62.            '.$liste_deroulante_taille.'
  63.         </select>
  64.                           </td>
  65.                         </tr>
  66.                         <tr bgcolor="#770B0B">
  67.                           <td><b><font size="1"></font></b></td>
  68.                           <td><b></b></td>
  69.                         </tr>
  70.        ';
  71.       }
  72.      }
  73.                      
  74.                       ?>
  75.                               <?
  76.                      
  77.                        $liste_couleur=$row[12];
  78.                        if(strlen($liste_couleur)!="0" ){
  79.                        $liste_couleur=explode(" - ",$liste_couleur);
  80.                      
  81.                      
  82.                        For($t=0;$t<count($liste_couleur);$t++){
  83.                         $liste_deroulante_couleur.='<option value="'.$liste_couleur[$t].'">'.$liste_couleur[$t].'</option>';
  84.                        }
  85.       if(isset($liste_deroulante_couleur)){
  86.        echo '
  87.                         <tr>
  88.                           <td align="right" height="25" bgcolor="#770B0B"><b><font color="#FFCC00" size="1">COULEURS
  89.                             :&nbsp;&nbsp;&nbsp;</font></b></td>
  90.                           <td class="texte">
  91.                          <select name="couleur" size="1">
  92.            '.$liste_deroulante_couleur.'
  93.         </select>
  94.         </td>
  95.                             </tr>
  96.                         <tr bgcolor="#770B0B">
  97.                           <td><b><font size="1"></font></b></td>
  98.                           <td><b></b></td>
  99.                         </tr>
  100.        ';
  101.       }
  102.      }
  103.                      
  104.                     ?>
  105.                               <?
  106.                      
  107.                        $liste_cote=$row[14];
  108.                        if(strlen($liste_cote)!="0" ){
  109.                        $liste_cote=explode(" - ",$liste_cote);
  110.                      
  111.                        For($t=0;$t<count($liste_cote);$t++){
  112.                         $liste_deroulante_cote.='<option value="'.$liste_cote[$t].'">'.$liste_cote[$t].'</option>';
  113.                        }
  114.       if(isset($liste_deroulante_cote)){
  115.        echo '
  116.         <tr>
  117.                           <td align="right" bgcolor="#770B0B" height="25"><b><font color="#FFCC00" size="1">COTE
  118.                             :&nbsp;&nbsp;&nbsp;</font></b></td>
  119.                           <td class="texte">
  120.                          <select name="cote" size="1">
  121.            '.$liste_deroulante_cote.'
  122.         </select>
  123.                           </td>
  124.                         </tr>
  125.                         <tr bgcolor="#770B0B">
  126.                           <td><b><font size="1"></font></b></td>
  127.                           <td><b></b></td>
  128.                         </tr>
  129.        ';
  130.       }
  131.      }
  132.                      
  133.                     ?>
  134.                               <?
  135.                      
  136.                        $liste_flex=$row[15];
  137.                        if(strlen($liste_flex)!="0" ){
  138.                        $liste_flex=explode(" - ",$liste_flex);
  139.                      
  140.                        For($t=0;$t<count($liste_flex);$t++){
  141.                         $liste_deroulante_flex.='<option value="'.$liste_flex[$t].'">'.$liste_flex[$t].'</option>';
  142.                        }
  143.       if(isset($liste_deroulante_flex)){
  144.        echo '
  145.                         <tr>
  146.                           <td align="right" bgcolor="#770B0B" height="25"><b><font color="#FFCC00" size="1">COURBES
  147.                             / FLEX:&nbsp;&nbsp;&nbsp;</font></b></td>
  148.                           <td class="texte">
  149.                          <select name="flex" size="1">
  150.            '.$liste_deroulante_flex.'
  151.         </select>
  152.                          </td>
  153.                        </tr>
  154.                        <tr bgcolor="#770B0B">
  155.                          <td><b><font size="1"></font></b></td>
  156.                          <td><b></b></td>
  157.                        </tr>
  158.        ';
  159.       }
  160.      }                     
  161.                     ?>
  162.                               <?
  163.   $fraisproduit1 = $row[8];
  164.   $fraisproduit2 = sprintf("%0.2f", $fraisproduit1);
  165. ?>


---------------
Merci Beaucoup
 
Steff
  FORUM Rue-Montgallet.com
  Programmation
  Php - Sql

  Pasage variable d'une page à l'autre

© 2000-2024 Forum.rue-montgallet.com - Tous droits réservés