Bonjour à vous,

Je suis en galère pour la création d'un panier php pour un site marchand.
Voici mon code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
 
<code type="php">
<?php
if(isset($_POST['libelle']))
$libelle=$_POST['libelle'];
else $libelle=NULL;
 
 
 
 
function ajout($select)
{
    array_push($_SESSION['panier']['libelle'],$select['lib']);
    array_push($_SESSION['panier']['qte'],$select['qte']);
 
    array_push($_SESSION['panier']['prix'],$select['prix']);
}
 
 
 
 
/* On vérifie l'existence du panier, sinon, on le crée */
if(!isset($_SESSION['panier']))
{
    /* Initialisation du panier */
    $_SESSION['panier'] = array();
    /* Subdivision du panier */
   	$_SESSION['panier']['libelle'] = array();
	$_SESSION['panier']['qte'] = array();
    $_SESSION['panier']['prix'] = array();
}
 
$select['lib'] = "cm123456";
$select['qte'] = 4;
$select['prix'] = 32.45;
array_push($_SESSION['panier']['libelle'],$select['lib']);
array_push($_SESSION['panier']['qte'],$select['qte']);
array_push($_SESSION['panier']['prix'],$select['prix']);
 
$select['id'] = "vm654321";
$select['qte'] = 1;
$select['prix'] = 434.95;
 
array_push($_SESSION['panier']['libelle'],$select['lib']);
array_push($_SESSION['panier']['qte'],$select['qte']);
array_push($_SESSION['panier']['prix'],$select['prix']); 
 
$select['lib'] = "osef";
$select['qte'] = 6;
$select['prix'] = 789.95;
ajout($select);				
 
 
/* Affichons maintenant le contenu du panier : */
 
 
var_dump($_SESSION['panier']);
 
 
?>
</code>
Et voici ce que j'obtiens:

<code type="html">
array(3) { ["libelle"]=> array(3) { [0]=> string(8) "cm123456" [1]=> string(8) "cm123456" [2]=> string(4) "osef" } ["qte"]=> array(3) { [0]=> int(4) [1]=> int(1) [2]=> int(6) } ["prix"]=> array(3) { [0]=> float(32.45) [1]=> float(434.95) [2]=> float(789.95) } }
</code>

Jusque là tout est normal sauf que les résultats ne sont pas enregistrer dans le panier, si je supprime les ajouts du code, je me retrouve avec un panier vide alors qu'il devrait les garder en mémoire non?

Je suis vraiment débutant en php et j'espère un peu d'aide :p

Merci.