Problème Session PHP
chickentib
-
le père -
le père -
Bonjour,
Je développe actuellement un site web marchant sur lequel j'ai installé une section membre et un panier utilisant tous les deux des sessions.
En début de chaque page, j'utilise bien session_start.
Lors de l'authentification, je fais:
$_SESSION['mail'] = $donnees['mail'];
Lors de l'ajout au panier, j'utilise la fonction suivante:
function creationPanier(){
if (!isset($_SESSION['panier'])){
$_SESSION['panier']=array();
$_SESSION['panier']['libelleProduit'] = array();
$_SESSION['panier']['qteProduit'] = array();
$_SESSION['panier']['prixProduit'] = array();
$_SESSION['panier']['verrou'] = false;
}
return true;
}
function ajouterArticle($libelleProduit,$qteProduit,$prixProduit){
//Si le panier existe
if (creationPanier() && !isVerrouille())
{
//Si le produit existe déjà on ajoute seulement la quantité
$positionProduit = array_search($libelleProduit, $_SESSION['panier']['libelleProduit']); //ligne 32
if ($positionProduit !== false)
{
$_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit ;
}
else
{
//Sinon on ajoute le produit
array_push( $_SESSION['panier']['libelleProduit'],$libelleProduit); //ligne 41
array_push( $_SESSION['panier']['qteProduit'],$qteProduit); //ligne 42
array_push( $_SESSION['panier']['prixProduit'],$prixProduit); //ligne 43
}
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
L'authentification le panier marche très bien séparemment, mais dès qu'un utilisateur se connecte et ajoute au panier, il obtient le message d'erreur suivant:
Warning: array_search() [function.array-search]: Wrong datatype for second argument in /home/site1835/web/www/panier/fonctions-panier.php on line 32
Warning: array_push() [function.array-push]: First argument should be an array in /home/site1835/web/www/panier/fonctions-panier.php on line 41
Warning: array_push() [function.array-push]: First argument should be an array in /home/site1835/web/www/panier/fonctions-panier.php on line 42
Warning: array_push() [function.array-push]: First argument should be an array in /home/site1835/web/www/panier/fonctions-panier.php on line 43
Quelqu'un pourrait-il m'aider??
Merci beaucoup
Je développe actuellement un site web marchant sur lequel j'ai installé une section membre et un panier utilisant tous les deux des sessions.
En début de chaque page, j'utilise bien session_start.
Lors de l'authentification, je fais:
$_SESSION['mail'] = $donnees['mail'];
Lors de l'ajout au panier, j'utilise la fonction suivante:
function creationPanier(){
if (!isset($_SESSION['panier'])){
$_SESSION['panier']=array();
$_SESSION['panier']['libelleProduit'] = array();
$_SESSION['panier']['qteProduit'] = array();
$_SESSION['panier']['prixProduit'] = array();
$_SESSION['panier']['verrou'] = false;
}
return true;
}
function ajouterArticle($libelleProduit,$qteProduit,$prixProduit){
//Si le panier existe
if (creationPanier() && !isVerrouille())
{
//Si le produit existe déjà on ajoute seulement la quantité
$positionProduit = array_search($libelleProduit, $_SESSION['panier']['libelleProduit']); //ligne 32
if ($positionProduit !== false)
{
$_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit ;
}
else
{
//Sinon on ajoute le produit
array_push( $_SESSION['panier']['libelleProduit'],$libelleProduit); //ligne 41
array_push( $_SESSION['panier']['qteProduit'],$qteProduit); //ligne 42
array_push( $_SESSION['panier']['prixProduit'],$prixProduit); //ligne 43
}
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
L'authentification le panier marche très bien séparemment, mais dès qu'un utilisateur se connecte et ajoute au panier, il obtient le message d'erreur suivant:
Warning: array_search() [function.array-search]: Wrong datatype for second argument in /home/site1835/web/www/panier/fonctions-panier.php on line 32
Warning: array_push() [function.array-push]: First argument should be an array in /home/site1835/web/www/panier/fonctions-panier.php on line 41
Warning: array_push() [function.array-push]: First argument should be an array in /home/site1835/web/www/panier/fonctions-panier.php on line 42
Warning: array_push() [function.array-push]: First argument should be an array in /home/site1835/web/www/panier/fonctions-panier.php on line 43
Quelqu'un pourrait-il m'aider??
Merci beaucoup
A voir également:
- Problème Session PHP
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
- Www.yahoomail.com ouverture de session - Forum Yahoo mail
- Teamviewer code de session expiré ✓ - Forum logiciel systeme
- Php alert ✓ - Forum PHP
12 réponses
Bonjour
Au début de la fonction ajouterArticle, ajoute :
Tu vas sans doute voir que $_SESSION ne contient pas ce que tu crois. Restera à voir pourquoi.
D'après tes messages, j'ai l'impression que $_SESSION['panier'] existe bien, mais que $_SESSION['panier']['libelleProduit'] etc ne sont pas des array.
Au début de la fonction ajouterArticle, ajoute :
echo '<pre>'; print_r($_SESSION); echo '</pre>';
Tu vas sans doute voir que $_SESSION ne contient pas ce que tu crois. Restera à voir pourquoi.
D'après tes messages, j'ai l'impression que $_SESSION['panier'] existe bien, mais que $_SESSION['panier']['libelleProduit'] etc ne sont pas des array.
Qu'entends-tu par "déclarer une session panier" et "déclarer une session d'authentification" ? En PHP, on ne "déclare" pas de session. On en ouvre
Habituellement, tu as une seule session en PHP, mais par contre tu peux avoir de nombreuses variables de session (ou plutôt, il y en a une seule, $_SESSION, mais c'est un tableau et tu mets tout ce que tu veux dedans). Il n'y a donc en principe aucun problème à gérer une authentification et un panier avec une seule et même session.
As-tu essayé d'afficher le contenu de la variable $_SESSION comme je te le suggérais ?
Habituellement, tu as une seule session en PHP, mais par contre tu peux avoir de nombreuses variables de session (ou plutôt, il y en a une seule, $_SESSION, mais c'est un tableau et tu mets tout ce que tu veux dedans). Il n'y a donc en principe aucun problème à gérer une authentification et un panier avec une seule et même session.
As-tu essayé d'afficher le contenu de la variable $_SESSION comme je te le suggérais ?
Tu vois bien que $_SESSION['panier']['libelleProduit'] n'est pas un array, il t'afficherait Array ()
Et comme ta fonction creationPanier initialise $_SESSION['panier'] correctement quand il n'est pas défini, c'est qu'une autre partie de ton script initialise - incorrectement - $_SESSION['panier']. Mais ça n'a pas l'air de se passer dans la partie de code que tu montres.
Peux-tu refaire le même test au début de ton script (juste après le session_start()) pour voir si ça ne vient pas d'une autre page ?
Et comme ta fonction creationPanier initialise $_SESSION['panier'] correctement quand il n'est pas défini, c'est qu'une autre partie de ton script initialise - incorrectement - $_SESSION['panier']. Mais ça n'a pas l'air de se passer dans la partie de code que tu montres.
Peux-tu refaire le même test au début de ton script (juste après le session_start()) pour voir si ça ne vient pas d'une autre page ?
Bonjour,
Je n'utilise nul part ailleurs la variable de session du panier...
Je ne comprend pas comment il peut y avoir une erreur lorsque la personne est authentifiée mais aucune lorsque le visiteur ne se connecte pas...
J'ai mis l'affichage du tableau de session sur plusieurs pages et cela donne toujours la même chose...
Je n'utilise nul part ailleurs la variable de session du panier...
Je ne comprend pas comment il peut y avoir une erreur lorsque la personne est authentifiée mais aucune lorsque le visiteur ne se connecte pas...
J'ai mis l'affichage du tableau de session sur plusieurs pages et cela donne toujours la même chose...
C'est sans doute que lors de l'authentification tu altères d'une manière ou d'une autre la variable $_SESSION['panier'].
Peux-tu montrer le code de l'authentification ? (sans montrer les identifiants)
Peux-tu montrer le code de l'authentification ? (sans montrer les identifiants)
Merci de ton aide!
Voilà le code lors de l'authentification:
//connexion au serveur
//selection de la BD
$reponse = mysql_query ("SELECT * FROM membre WHERE mail='$email'"); //On recupère les infos à partir du pseudo
$num_rows = mysql_num_rows($reponse);
$donnees = mysql_fetch_array ($reponse);
mysql_close($linkid); //On ferme la connection
if(($num_rows==0)||(md5($pass) != $donnees['pass'])) //On verifie que le pass entré est égale à celui de la BDD, si le passe est différent
{
if ($lang=='fr')
$erreur = 'Votre email ou votre code secret est incorrect';
if ($lang=='en')
$erreur = 'Invalid mail or password';
}
else //Sinon tout est bon
{
$_SESSION['mail'] = $donnees['mail']; //On créé une variable session avec le mail
$_SESSION['nom'] = $donnees['nom'];
$_SESSION['prenom'] = $donnees['prenom'];
header ('Location: espacemembre.php?lang='.$lang);
exit();
}
Voilà le code lors de l'authentification:
//connexion au serveur
//selection de la BD
$reponse = mysql_query ("SELECT * FROM membre WHERE mail='$email'"); //On recupère les infos à partir du pseudo
$num_rows = mysql_num_rows($reponse);
$donnees = mysql_fetch_array ($reponse);
mysql_close($linkid); //On ferme la connection
if(($num_rows==0)||(md5($pass) != $donnees['pass'])) //On verifie que le pass entré est égale à celui de la BDD, si le passe est différent
{
if ($lang=='fr')
$erreur = 'Votre email ou votre code secret est incorrect';
if ($lang=='en')
$erreur = 'Invalid mail or password';
}
else //Sinon tout est bon
{
$_SESSION['mail'] = $donnees['mail']; //On créé une variable session avec le mail
$_SESSION['nom'] = $donnees['nom'];
$_SESSION['prenom'] = $donnees['prenom'];
header ('Location: espacemembre.php?lang='.$lang);
exit();
}
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Donc ça ne vient pas d elà
Tu as écrit :
Je n'utilise nul part ailleurs la variable de session du panier
Peux-tu le confirmer ? Et montrer la totalisé du script du panier ? car ce que tu montres message 4 correspond à une mauvaise initialisation du panier (ou une modification a posteriori), et elle ne vient pas de la partie que tu as montrée
Tu as écrit :
Je n'utilise nul part ailleurs la variable de session du panier
Peux-tu le confirmer ? Et montrer la totalisé du script du panier ? car ce que tu montres message 4 correspond à une mauvaise initialisation du panier (ou une modification a posteriori), et elle ne vient pas de la partie que tu as montrée
voila panier.php
<?php
include_once('/home/site1835/web/www/include/confphp.inc');
include_once('fonctions-panier.php');
$erreur = false;
if(isset($_POST['valider']))
{
header('Location: https://www.musiclassroom.com/panier/identification.php?lang=%27$lang);
exit;
}
$action = (isset($_POST['action'])? $_POST['action']: (isset($_GET['action'])? $_GET['action']:null )) ;
if($action !== null)
{
if(!in_array($action,array('ajout', 'suppression', 'refresh')))
$erreur=true;
//récuperation des variables en POST ou GET
$l = (isset($_POST['l'])? $_POST['l']: (isset($_GET['l'])? $_GET['l']:null )) ;
$p = (isset($_POST['p'])? $_POST['p']: (isset($_GET['p'])? $_GET['p']:null )) ;
$q = (isset($_POST['q'])? $_POST['q']: (isset($_GET['q'])? $_GET['q']:null )) ;
//Suppression des espaces verticaux
$l = preg_replace('#\v#', '',$l);
//On verifie que $p soit un float
$p = floatval($p);
//On traite $q qui peut etre un entier simple ou un tableau d'entier
if (is_array($q)){
$QteArticle = array();
$i=0;
foreach ($q as $contenu){
$QteArticle[$i++] = intval($contenu);
}
}
else
$q = intval($q);
}
if (!$erreur){
switch($action){
Case "ajout":
ajouterArticle($l,$q,$p);
break;
Case "suppression":
supprimerArticle($l);
break;
Case "refresh" :
for ($i = 0 ; $i < count($QteArticle) ; $i++)
{
modifierQTeArticle($_SESSION['panier']['libelleProduit'][$i],round($QteArticle[$i]));
}
break;
Default:
break;
}
}
echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:(null)0="http://www.w3.org/TR/REC-html40/">
<head>
<title><?php if($lang=='fr') echo "Etape 1 - Votre panier";
if($lang=='en') echo "Step 1 - Your cart"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-language" content="fr,en">
<meta name="Copyright" content="<?php if($lang=='fr') echo "tous droits audio et video reserves 2007";
if($lang=='en') echo "all audio and videos rights reserved 2007"; ?>">
<meta name="Revisit-after" content="14 days">
<meta name="Robots" content="all">
<meta name="author" content="yves feger">
<meta name="Identifier-URL" content="https://www.musiclassroom.com/classe.php">
<link rel="stylesheet" type="text/css" href="https://www.musiclassroom.com/include/style2.css" media="screen" />
</head>
<body>
<?php
include('/home/site1835/web/www/include/header.inc');
include('/home/site1835/web/www/include/menu20.inc');
?>
<table style="border-collapse: collapse;" align='center' id="AutoNumber1" width="70%" bgcolor="#eaeaea" border="1" bordercolor="black">
<tr>
<td bordercolor="#D7D7D7" align="left">
<BR/>
<p align="center">
<font size="7" color="#999999">
<?php if ($lang=='fr') echo 'Votre panier';
if ($lang=='en') echo 'Your cart';?>
</font>
<p align="center">____</p>
</p>
<BR/><BR/>
<form method="post" action="panier.php?lang=<?php echo $lang; ?>">
<table width='50%' align='center'>
<tr>
<th>
<?php if ($lang=='fr') echo 'Libellé';
if ($lang=='en') echo 'Name';?>
</th>
<th>
<?php if ($lang=='fr') echo 'Quantité';
if ($lang=='en') echo 'Quantity';?>
</th>
<th>
<?php if ($lang=='fr') echo 'Prix Unitaire';
if ($lang=='en') echo 'Unit Price';?>
</th>
<th>
<?php if ($lang=='fr') echo 'Supprimer';
if ($lang=='en') echo 'Delete';?>
</th>
</tr>
<?php
if (creationPanier())
{
$nbArticles=count($_SESSION['panier']['libelleProduit']);
if ($nbArticles <= 0)
{
if ($lang=='fr') echo "<tr><td>Votre panier est vide</td></tr>";
if ($lang=='en') echo "<tr><td>Your cart is empty</td></tr>";
}
else
{
for ($i=0 ;$i < $nbArticles ; $i++)
{
echo "<tr>";
echo "<td>".htmlspecialchars($_SESSION['panier']['libelleProduit'][$i])."</ td>";
echo "<td><input type=\"text\" size=\"4\" name=\"q[]\" value=\"".htmlspecialchars($_SESSION['panier']['qteProduit'][$i])."\"/></td>";
echo "<td>".htmlspecialchars($_SESSION['panier']['prixProduit'][$i]);
if($lang=='fr') echo " €</td>";
if($lang=='en') echo " $</td>";
echo "<td align='center'><a href=\"".htmlspecialchars("panier.php?action=suppression&l=".rawurlencode($_SESSION['panier']['libelleProduit'][$i]))."\"><img border='0' width='30' src='http://www.musiclassroom.com/images/poubelle8.gif'></a></td>";
echo "</tr>";
}
echo "<tr><td colspan=\"2\"> </td>";
echo "<td colspan=\"2\">";
echo "<b>Total : ".MontantGlobal();
if($lang=='fr') echo " €</b>";
if($lang=='en') echo " $</b>";
echo "</td></tr>";
echo "<tr><td colspan=\"4\">";
echo "<br/><br/><center>";
echo "<a href='http://www.musiclassroom.com/boutique.php?lang=".$lang."'><font color='#FF0000'>";
if ($lang=='fr') echo "Poursuivre vos achats";
if ($lang=='en') echo "Continue your purchase";
echo "</font></a><br/><br/>
<img border='0' width='38%' src='https://www.paypalobjects.com/WEBSCR-610-20100112-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif'><br/><br/>";
if ($lang=='fr') echo "<input type=\"submit\" name='refresh' value=\"Rafraichir\"/>";
if ($lang=='en') echo "<input type=\"submit\" name='refresh' value=\"Refresh\"/>";
if ($lang=='fr') echo "<input type=\"submit\" name='valider' value=\"Valider\"/>";
if ($lang=='en') echo "<input type=\"submit\" name='valider' value=\"OK\"/>";
echo "</center";
echo "<input type=\"hidden\" name=\"action\" value=\"refresh\"/>";
echo "</td></tr>";
}
}
?>
<tr>
<td align='center' colspan=4>
</td>
</tr>
</table>
</form>
<br/>
</td>
</tr>
</table>
<p align="center"> <!--Footer-->
<?php
include('/home/site1835/web/www/include/menufin.inc');
$page = 'panier'.$lang;
include('/home/site1835/web/www/include/xiti.inc');
include('/home/site1835/web/www/include/google.inc');
?>
</p>
</body>
</html>
<?php
include_once('/home/site1835/web/www/include/confphp.inc');
include_once('fonctions-panier.php');
$erreur = false;
if(isset($_POST['valider']))
{
header('Location: https://www.musiclassroom.com/panier/identification.php?lang=%27$lang);
exit;
}
$action = (isset($_POST['action'])? $_POST['action']: (isset($_GET['action'])? $_GET['action']:null )) ;
if($action !== null)
{
if(!in_array($action,array('ajout', 'suppression', 'refresh')))
$erreur=true;
//récuperation des variables en POST ou GET
$l = (isset($_POST['l'])? $_POST['l']: (isset($_GET['l'])? $_GET['l']:null )) ;
$p = (isset($_POST['p'])? $_POST['p']: (isset($_GET['p'])? $_GET['p']:null )) ;
$q = (isset($_POST['q'])? $_POST['q']: (isset($_GET['q'])? $_GET['q']:null )) ;
//Suppression des espaces verticaux
$l = preg_replace('#\v#', '',$l);
//On verifie que $p soit un float
$p = floatval($p);
//On traite $q qui peut etre un entier simple ou un tableau d'entier
if (is_array($q)){
$QteArticle = array();
$i=0;
foreach ($q as $contenu){
$QteArticle[$i++] = intval($contenu);
}
}
else
$q = intval($q);
}
if (!$erreur){
switch($action){
Case "ajout":
ajouterArticle($l,$q,$p);
break;
Case "suppression":
supprimerArticle($l);
break;
Case "refresh" :
for ($i = 0 ; $i < count($QteArticle) ; $i++)
{
modifierQTeArticle($_SESSION['panier']['libelleProduit'][$i],round($QteArticle[$i]));
}
break;
Default:
break;
}
}
echo '<?xml version="1.0" encoding="utf-8"?>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:(null)0="http://www.w3.org/TR/REC-html40/">
<head>
<title><?php if($lang=='fr') echo "Etape 1 - Votre panier";
if($lang=='en') echo "Step 1 - Your cart"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-language" content="fr,en">
<meta name="Copyright" content="<?php if($lang=='fr') echo "tous droits audio et video reserves 2007";
if($lang=='en') echo "all audio and videos rights reserved 2007"; ?>">
<meta name="Revisit-after" content="14 days">
<meta name="Robots" content="all">
<meta name="author" content="yves feger">
<meta name="Identifier-URL" content="https://www.musiclassroom.com/classe.php">
<link rel="stylesheet" type="text/css" href="https://www.musiclassroom.com/include/style2.css" media="screen" />
</head>
<body>
<?php
include('/home/site1835/web/www/include/header.inc');
include('/home/site1835/web/www/include/menu20.inc');
?>
<table style="border-collapse: collapse;" align='center' id="AutoNumber1" width="70%" bgcolor="#eaeaea" border="1" bordercolor="black">
<tr>
<td bordercolor="#D7D7D7" align="left">
<BR/>
<p align="center">
<font size="7" color="#999999">
<?php if ($lang=='fr') echo 'Votre panier';
if ($lang=='en') echo 'Your cart';?>
</font>
<p align="center">____</p>
</p>
<BR/><BR/>
<form method="post" action="panier.php?lang=<?php echo $lang; ?>">
<table width='50%' align='center'>
<tr>
<th>
<?php if ($lang=='fr') echo 'Libellé';
if ($lang=='en') echo 'Name';?>
</th>
<th>
<?php if ($lang=='fr') echo 'Quantité';
if ($lang=='en') echo 'Quantity';?>
</th>
<th>
<?php if ($lang=='fr') echo 'Prix Unitaire';
if ($lang=='en') echo 'Unit Price';?>
</th>
<th>
<?php if ($lang=='fr') echo 'Supprimer';
if ($lang=='en') echo 'Delete';?>
</th>
</tr>
<?php
if (creationPanier())
{
$nbArticles=count($_SESSION['panier']['libelleProduit']);
if ($nbArticles <= 0)
{
if ($lang=='fr') echo "<tr><td>Votre panier est vide</td></tr>";
if ($lang=='en') echo "<tr><td>Your cart is empty</td></tr>";
}
else
{
for ($i=0 ;$i < $nbArticles ; $i++)
{
echo "<tr>";
echo "<td>".htmlspecialchars($_SESSION['panier']['libelleProduit'][$i])."</ td>";
echo "<td><input type=\"text\" size=\"4\" name=\"q[]\" value=\"".htmlspecialchars($_SESSION['panier']['qteProduit'][$i])."\"/></td>";
echo "<td>".htmlspecialchars($_SESSION['panier']['prixProduit'][$i]);
if($lang=='fr') echo " €</td>";
if($lang=='en') echo " $</td>";
echo "<td align='center'><a href=\"".htmlspecialchars("panier.php?action=suppression&l=".rawurlencode($_SESSION['panier']['libelleProduit'][$i]))."\"><img border='0' width='30' src='http://www.musiclassroom.com/images/poubelle8.gif'></a></td>";
echo "</tr>";
}
echo "<tr><td colspan=\"2\"> </td>";
echo "<td colspan=\"2\">";
echo "<b>Total : ".MontantGlobal();
if($lang=='fr') echo " €</b>";
if($lang=='en') echo " $</b>";
echo "</td></tr>";
echo "<tr><td colspan=\"4\">";
echo "<br/><br/><center>";
echo "<a href='http://www.musiclassroom.com/boutique.php?lang=".$lang."'><font color='#FF0000'>";
if ($lang=='fr') echo "Poursuivre vos achats";
if ($lang=='en') echo "Continue your purchase";
echo "</font></a><br/><br/>
<img border='0' width='38%' src='https://www.paypalobjects.com/WEBSCR-610-20100112-1/en_US/FR/i/bnr/bnr_horizontal_solution_PP_327wx80h.gif'><br/><br/>";
if ($lang=='fr') echo "<input type=\"submit\" name='refresh' value=\"Rafraichir\"/>";
if ($lang=='en') echo "<input type=\"submit\" name='refresh' value=\"Refresh\"/>";
if ($lang=='fr') echo "<input type=\"submit\" name='valider' value=\"Valider\"/>";
if ($lang=='en') echo "<input type=\"submit\" name='valider' value=\"OK\"/>";
echo "</center";
echo "<input type=\"hidden\" name=\"action\" value=\"refresh\"/>";
echo "</td></tr>";
}
}
?>
<tr>
<td align='center' colspan=4>
</td>
</tr>
</table>
</form>
<br/>
</td>
</tr>
</table>
<p align="center"> <!--Footer-->
<?php
include('/home/site1835/web/www/include/menufin.inc');
$page = 'panier'.$lang;
include('/home/site1835/web/www/include/xiti.inc');
include('/home/site1835/web/www/include/google.inc');
?>
</p>
</body>
</html>
Je ne vois rien qui me choque
Pourrais-tu
1 - remettre le print_r($_SESSION) entre le include_once('/home/site1835/web/www/include/confphp.inc'); et le include_once('fonctions-panier.php');
2 - dire ce qui s'affiche avec un utilisateur authentifié
3 - dire ce qui s'affiche avec un utilisateur non authentifié
4 - montrer le code de fonctions-panier.php
Pourrais-tu
1 - remettre le print_r($_SESSION) entre le include_once('/home/site1835/web/www/include/confphp.inc'); et le include_once('fonctions-panier.php');
2 - dire ce qui s'affiche avec un utilisateur authentifié
3 - dire ce qui s'affiche avec un utilisateur non authentifié
4 - montrer le code de fonctions-panier.php
fonctions-panier.php
<?php
/**
* Verifie si le panier existe, le créé sinon
* @return booleen
*/
function creationPanier(){
if (!isset($_SESSION['panier'])){
$_SESSION['panier']=array();
$_SESSION['panier']['libelleProduit'] = array();
$_SESSION['panier']['qteProduit'] = array();
$_SESSION['panier']['prixProduit'] = array();
$_SESSION['panier']['verrou'] = false;
}
return true;
}
/**
* Ajoute un article dans le panier
* @param string $libelleProduit
* @param int $qteProduit
* @param float $prixProduit
* @return void
*/
function ajouterArticle($libelleProduit,$qteProduit,$prixProduit){
//Si le panier existe
if (creationPanier() && !isVerrouille())
{
//Si le produit existe déjà on ajoute seulement la quantité
$positionProduit = array_search($libelleProduit, $_SESSION['panier']['libelleProduit']);
if ($positionProduit !== false)
{
$_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit ;
}
else
{
//Sinon on ajoute le produit
array_push( $_SESSION['panier']['libelleProduit'],$libelleProduit);
array_push( $_SESSION['panier']['qteProduit'],$qteProduit);
array_push( $_SESSION['panier']['prixProduit'],$prixProduit);
}
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
/**
* Modifie la quantité d'un article
* @param $libelleProduit
* @param $qteProduit
* @return void
*/
function modifierQTeArticle($libelleProduit,$qteProduit){
//Si le panier éxiste
if (creationPanier() && !isVerrouille())
{
//Si la quantité est positive on modifie sinon on supprime l'article
if ($qteProduit > 0)
{
//Recharche du produit dans le panier
$positionProduit = array_search($libelleProduit, $_SESSION['panier']['libelleProduit']);
if ($positionProduit !== false)
{
$_SESSION['panier']['qteProduit'][$positionProduit] = $qteProduit ;
}
}
else
supprimerArticle($libelleProduit);
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
/**
* Supprime un article du panier
* @param $libelleProduit
* @return unknown_type
*/
function supprimerArticle($libelleProduit){
//Si le panier existe
if (creationPanier() && !isVerrouille())
{
//Nous allons passer par un panier temporaire
$tmp=array();
$tmp['libelleProduit'] = array();
$tmp['qteProduit'] = array();
$tmp['prixProduit'] = array();
$tmp['verrou'] = $_SESSION['panier']['verrou'];
for($i = 0; $i < count($_SESSION['panier']['libelleProduit']); $i++)
{
if ($_SESSION['panier']['libelleProduit'][$i] !== $libelleProduit)
{
array_push( $tmp['libelleProduit'],$_SESSION['panier']['libelleProduit'][$i]);
array_push( $tmp['qteProduit'],$_SESSION['panier']['qteProduit'][$i]);
array_push( $tmp['prixProduit'],$_SESSION['panier']['prixProduit'][$i]);
}
}
//On remplace le panier en session par notre panier temporaire à jour
$_SESSION['panier'] = $tmp;
//On efface notre panier temporaire
unset($tmp);
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
/**
* Montant total du panier
* @return int
*/
function MontantGlobal(){
$total=0;
for($i = 0; $i < count($_SESSION['panier']['libelleProduit']); $i++)
{
$total += $_SESSION['panier']['qteProduit'][$i] * $_SESSION['panier']['prixProduit'][$i];
}
return $total;
}
/**
* Fonction de suppression du panier
* @return void
*/
function supprimePanier(){
unset($_SESSION['panier']);
}
/**
* Permet de savoir si le panier est verrouillé
* @return booleen
*/
function isVerrouille(){
if (isset($_SESSION['panier']) && $_SESSION['panier']['verrou'])
return true;
else
return false;
}
/**
* Compte le nombre d'articles différents dans le panier
* @return int
*/
function compterArticles()
{
if (isset($_SESSION['panier']))
return count($_SESSION['panier']['libelleProduit']);
else
return 0;
}
?>
Tableau de session à l'ajout d'un article sans authentification:
En début de page:
Array
(
)
En fin de page:
Array
(
[panier] => Array
(
[libelleProduit] => Array
(
[0] => La Théorie
)
[qteProduit] => Array
(
[0] => 1
)
[prixProduit] => Array
(
[0] => 22
)
[verrou] =>
)
)
Tableau de session à l'ajout d'un article avecauthentification:
En début de page:
Array
(
[panier] =>
[mail] => poulet.thibault@gmail.com
[nom] => tib4
[prenom] => tib
)
puis les 4 erreurs...
En fin de page:
Array
(
[panier] => Array
(
[libelleProduit] =>
[qteProduit] =>
[prixProduit] =>
)
[mail] => poulet.thibault@gmail.com
[nom] => tib4
[prenom] => tib
)
<?php
/**
* Verifie si le panier existe, le créé sinon
* @return booleen
*/
function creationPanier(){
if (!isset($_SESSION['panier'])){
$_SESSION['panier']=array();
$_SESSION['panier']['libelleProduit'] = array();
$_SESSION['panier']['qteProduit'] = array();
$_SESSION['panier']['prixProduit'] = array();
$_SESSION['panier']['verrou'] = false;
}
return true;
}
/**
* Ajoute un article dans le panier
* @param string $libelleProduit
* @param int $qteProduit
* @param float $prixProduit
* @return void
*/
function ajouterArticle($libelleProduit,$qteProduit,$prixProduit){
//Si le panier existe
if (creationPanier() && !isVerrouille())
{
//Si le produit existe déjà on ajoute seulement la quantité
$positionProduit = array_search($libelleProduit, $_SESSION['panier']['libelleProduit']);
if ($positionProduit !== false)
{
$_SESSION['panier']['qteProduit'][$positionProduit] += $qteProduit ;
}
else
{
//Sinon on ajoute le produit
array_push( $_SESSION['panier']['libelleProduit'],$libelleProduit);
array_push( $_SESSION['panier']['qteProduit'],$qteProduit);
array_push( $_SESSION['panier']['prixProduit'],$prixProduit);
}
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
/**
* Modifie la quantité d'un article
* @param $libelleProduit
* @param $qteProduit
* @return void
*/
function modifierQTeArticle($libelleProduit,$qteProduit){
//Si le panier éxiste
if (creationPanier() && !isVerrouille())
{
//Si la quantité est positive on modifie sinon on supprime l'article
if ($qteProduit > 0)
{
//Recharche du produit dans le panier
$positionProduit = array_search($libelleProduit, $_SESSION['panier']['libelleProduit']);
if ($positionProduit !== false)
{
$_SESSION['panier']['qteProduit'][$positionProduit] = $qteProduit ;
}
}
else
supprimerArticle($libelleProduit);
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
/**
* Supprime un article du panier
* @param $libelleProduit
* @return unknown_type
*/
function supprimerArticle($libelleProduit){
//Si le panier existe
if (creationPanier() && !isVerrouille())
{
//Nous allons passer par un panier temporaire
$tmp=array();
$tmp['libelleProduit'] = array();
$tmp['qteProduit'] = array();
$tmp['prixProduit'] = array();
$tmp['verrou'] = $_SESSION['panier']['verrou'];
for($i = 0; $i < count($_SESSION['panier']['libelleProduit']); $i++)
{
if ($_SESSION['panier']['libelleProduit'][$i] !== $libelleProduit)
{
array_push( $tmp['libelleProduit'],$_SESSION['panier']['libelleProduit'][$i]);
array_push( $tmp['qteProduit'],$_SESSION['panier']['qteProduit'][$i]);
array_push( $tmp['prixProduit'],$_SESSION['panier']['prixProduit'][$i]);
}
}
//On remplace le panier en session par notre panier temporaire à jour
$_SESSION['panier'] = $tmp;
//On efface notre panier temporaire
unset($tmp);
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
/**
* Montant total du panier
* @return int
*/
function MontantGlobal(){
$total=0;
for($i = 0; $i < count($_SESSION['panier']['libelleProduit']); $i++)
{
$total += $_SESSION['panier']['qteProduit'][$i] * $_SESSION['panier']['prixProduit'][$i];
}
return $total;
}
/**
* Fonction de suppression du panier
* @return void
*/
function supprimePanier(){
unset($_SESSION['panier']);
}
/**
* Permet de savoir si le panier est verrouillé
* @return booleen
*/
function isVerrouille(){
if (isset($_SESSION['panier']) && $_SESSION['panier']['verrou'])
return true;
else
return false;
}
/**
* Compte le nombre d'articles différents dans le panier
* @return int
*/
function compterArticles()
{
if (isset($_SESSION['panier']))
return count($_SESSION['panier']['libelleProduit']);
else
return 0;
}
?>
Tableau de session à l'ajout d'un article sans authentification:
En début de page:
Array
(
)
En fin de page:
Array
(
[panier] => Array
(
[libelleProduit] => Array
(
[0] => La Théorie
)
[qteProduit] => Array
(
[0] => 1
)
[prixProduit] => Array
(
[0] => 22
)
[verrou] =>
)
)
Tableau de session à l'ajout d'un article avecauthentification:
En début de page:
Array
(
[panier] =>
[mail] => poulet.thibault@gmail.com
[nom] => tib4
[prenom] => tib
)
puis les 4 erreurs...
En fin de page:
Array
(
[panier] => Array
(
[libelleProduit] =>
[qteProduit] =>
[prixProduit] =>
)
[mail] => poulet.thibault@gmail.com
[nom] => tib4
[prenom] => tib
)
Tableau de session à l'ajout d'un article avecauthentification:
En début de page:
Array
(
[panier] =>
Ce qui confirme ce que je disais dans le message 1 : $_SESSION['panier'] existe bien mais est incorrect.
Je regarde le code que tu viens de mettre.
En début de page:
Array
(
[panier] =>
Ce qui confirme ce que je disais dans le message 1 : $_SESSION['panier'] existe bien mais est incorrect.
Je regarde le code que tu viens de mettre.
Je ne vois toujours pas d'où ça peut venir. Mais comme le défaut est déjà présent au début de la page, ça doit venir d'avant.
Es-tu sûr que tu ne touches à $_SESSION[panier'] nulle part ailleurs ?
Peux-tu montrer espacemembre.php ?
Es-tu sûr que tu ne touches à $_SESSION[panier'] nulle part ailleurs ?
Peux-tu montrer espacemembre.php ?
espacemembre.php
<?php
include('/home/site1835/web/www/include/confphp.inc');
if (!isset($_SESSION['mail']))
{
header("location:index.php?lang=".$lang);
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:(null)0="http://www.w3.org/TR/REC-html40/">
<head>
<title><?php if($lang=='fr') echo "Espace membre";
if($lang=='en') echo "Member section"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-language" content="fr">
<meta name="Copyright" content="tous droits audio et video reserves 2007">
<meta name="Revisit-after" content="14 days">
<meta name="Robots" content="all">
<meta name="author" content="yves feger">
<meta name="Identifier-URL" content="https://www.musiclassroom.com/membre/espacemembre.php">
<meta name="description" content="<?php if($lang=='fr') echo "Espace membre";
if($lang=='en') echo "Member section"; ?>">
<meta name="keywords" content="<b>formation musicale</b>,<b>enseignement</b>,<b>musique</b>,<b>piano</b>,<b>dvd</b>,<b>cd</b>,<b>mp3</b>,<b>livres</b>,<b>methodes</b>,<b>partitions</b>,<b>composition</b>,<b>harmonie</b>,<b>arrangement</b>,orchestration,<b>chanson</b>,<b>jazz</b>,<b>improvisation</b>,<b>classique</b>,<b>oreille</b>,<b>world music</b>,<b>accompagnement</b>, <b>feger</b>">
<link rel="stylesheet" type="text/css" href="https://www.musiclassroom.com/include/style2.css" media="screen" />
<link rel="stylesheet" type="text/css" href="https://www.musiclassroom.com/include/menu2.css" media="screen" />
</head>
<body style="margin-top:0px">
<?php
include('/home/site1835/web/www/include/header.inc');
include('/home/site1835/web/www/include/menu20.inc');
?>
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#00003E" width="828" id="AutoNumber1" height="394" bgcolor="#DDDDDD">
<tr>
<td width="1330" height="377" bordercolor="#C0C0C0" align="left">
<BR/><br/>
<p align="center" style="margin-bottom: -20">
<font size="7" color="#999999">
<?php if ($lang=='fr') echo 'Espace Membre';
if ($lang=='en') echo 'Member section';?>
</font>
</p>
<p align="center">
<img border="0" src="http://www.musiclassroom.com/images/vip2.jpg" width="70" height="70"></p>
<p align="right" style="line-height: 100%; margin-bottom: 10">
<font color="#E43C15">
<a target="_top" href="https://www.musiclassroom.com/membre/deconnexion.php?lang=<?php echo $lang; ?>">
<?php if ($lang=='fr') echo 'Déconnexion';
if ($lang=='en') echo 'Disconnect';?>
</a>
<BR/><BR/>
<a target="_top" href="https://www.musiclassroom.com/membre/changeinfo.php?lang=<?php echo $lang; ?>">
<?php if ($lang=='fr')
echo 'Mon compte / Modifier';
if ($lang=='en')
echo 'My account / Modify';
?>
</a>
</font>
</p>
<BR/><BR/>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="25%">
<p align="center"><b><font color="#274F76" size="5">
<?php
if($lang=='fr') echo 'Cours';
if($lang=='en') echo 'Lessons';
?></font></b></p>
</td>
<td width="25%">
<p align="center"><b><font color="#274F76" size="5">
<?php
if($lang=='fr') echo 'Téléchargements';
if($lang=='en') echo 'Downloads';
?></font></b></p>
</td>
<td width="25%">
<p align="center"><b><font color="#274F76" size="5">
<?php
if($lang=='fr') echo 'Vidéos';
if($lang=='en') echo 'Videos';
?></font></b></p>
</td>
<td width="25%">
<p align="center"><b><font color="#274F76" size="5">Exercices</font></b></p>
</td>
</tr>
<tr>
<td width="25%" align='center' valign='top'>
<p align="center"><font color="#274F76">
<?php if($lang=='fr') echo 'Poursuivez vos cours:';
if($lang=='en') echo 'Continue your lessons:'; ?>
</font><br/><br/>
<?php
//connexion au serveur
//selection de la BD
$req2 = "****";
$reponse2 = mysql_query ($req2);
while($courspayant = mysql_fetch_array($reponse2))
{
echo "<a href='./cours/".$courspayant['LienCoursPayant']."?lang=".$lang."'>".$courspayant['Nom_'.$lang.'_CoursPayant']."</a><BR/><BR/>";
}
mysql_close($linkid);
?>
</td>
<td width="25%" valign='top'>
<p align="center"><font color="#274F76">
<?php if($lang=='fr') echo 'Téléchargez les ebooks:';
if($lang=='en') echo 'Downloads ebooks:'; ?>
</font><br/><br/>
<?php
//connexion au serveur
//selection de la BD
if($lang=='fr') $req3 = "***";
if($lang=='en') $req3 = "***";
$reponse3 = mysql_query ($req3);
while($panier = mysql_fetch_array($reponse3))
{
if ($lang=='fr') $cond = split(' Telechargement',$panier['produit']);
if ($lang=='en') $cond = split(' Download',$panier['produit']);
$req4 = "***";
$reponse4 = mysql_query ($req4);
$cours = mysql_fetch_array($reponse4);
echo "<a href='download2.php?".$cours['LienDownloads']."'>".$cours['FichierDownloads']."</a><BR/><BR/>";
}
mysql_close($linkid);
?>
</td>
<td width="25%" valign='top'>
<p align="center"><font color="#274F76">
<?php if($lang=='fr') echo 'Visionnez les vidéos:';
if($lang=='en') echo 'See the videos:'; ?>
</font><br/><br/>
<?php
//connexion au serveur
//selection de la BD
if($lang=='fr') $req5 = "***";
if($lang=='en') $req5 = "***";
$reponse5 = mysql_query ($req5);
while($panier = mysql_fetch_array($reponse5))
{
if ($lang=='fr') $cond = split(' Vidéo',$panier['produit']);
if ($lang=='en') $cond = split(' Videos',$panier['produit']);
$req6 = "***";
$reponse6 = mysql_query ($req6);
$cours = mysql_fetch_array($reponse6);
echo "<a href='".$cours['classe'.$lang]."'>".$cours['titre2'.$lang]."</a><BR/><BR/>";
}
mysql_close($linkid);
?>
</td>
<td width="25%" valign='top'>
<p align="center"><font color="#274F76">
<?php if($lang=='fr') echo 'Téléchargez les exercices:';
if($lang=='en') echo 'Download the exercices:'; ?>
</font><br/><br/>
<?php
//connexion au serveur
//selection de la BD
$req7 = "***";
$reponse7 = mysql_query ($req7);
while($panier = mysql_fetch_array($reponse7))
{
$cond = split(' Exercices',$panier['produit']);
$req8 = "***";
$reponse8 = mysql_query ($req8);
$cours = mysql_fetch_array($reponse8);
echo "<a href='".$cours['classe'.$lang]."'>".$cours['titre2'.$lang]."</a><BR/><BR/>";
}
mysql_close($linkid);
?>
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</center>
</div>
<BR/><BR/>
<?php
include('../include/menufin.inc');
include('../include/xiti.inc');
include('../include/google.inc');
?>
</div>
</body>
</html>
<?php
include('/home/site1835/web/www/include/confphp.inc');
if (!isset($_SESSION['mail']))
{
header("location:index.php?lang=".$lang);
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:(null)0="http://www.w3.org/TR/REC-html40/">
<head>
<title><?php if($lang=='fr') echo "Espace membre";
if($lang=='en') echo "Member section"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-language" content="fr">
<meta name="Copyright" content="tous droits audio et video reserves 2007">
<meta name="Revisit-after" content="14 days">
<meta name="Robots" content="all">
<meta name="author" content="yves feger">
<meta name="Identifier-URL" content="https://www.musiclassroom.com/membre/espacemembre.php">
<meta name="description" content="<?php if($lang=='fr') echo "Espace membre";
if($lang=='en') echo "Member section"; ?>">
<meta name="keywords" content="<b>formation musicale</b>,<b>enseignement</b>,<b>musique</b>,<b>piano</b>,<b>dvd</b>,<b>cd</b>,<b>mp3</b>,<b>livres</b>,<b>methodes</b>,<b>partitions</b>,<b>composition</b>,<b>harmonie</b>,<b>arrangement</b>,orchestration,<b>chanson</b>,<b>jazz</b>,<b>improvisation</b>,<b>classique</b>,<b>oreille</b>,<b>world music</b>,<b>accompagnement</b>, <b>feger</b>">
<link rel="stylesheet" type="text/css" href="https://www.musiclassroom.com/include/style2.css" media="screen" />
<link rel="stylesheet" type="text/css" href="https://www.musiclassroom.com/include/menu2.css" media="screen" />
</head>
<body style="margin-top:0px">
<?php
include('/home/site1835/web/www/include/header.inc');
include('/home/site1835/web/www/include/menu20.inc');
?>
<div align="center">
<center>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#00003E" width="828" id="AutoNumber1" height="394" bgcolor="#DDDDDD">
<tr>
<td width="1330" height="377" bordercolor="#C0C0C0" align="left">
<BR/><br/>
<p align="center" style="margin-bottom: -20">
<font size="7" color="#999999">
<?php if ($lang=='fr') echo 'Espace Membre';
if ($lang=='en') echo 'Member section';?>
</font>
</p>
<p align="center">
<img border="0" src="http://www.musiclassroom.com/images/vip2.jpg" width="70" height="70"></p>
<p align="right" style="line-height: 100%; margin-bottom: 10">
<font color="#E43C15">
<a target="_top" href="https://www.musiclassroom.com/membre/deconnexion.php?lang=<?php echo $lang; ?>">
<?php if ($lang=='fr') echo 'Déconnexion';
if ($lang=='en') echo 'Disconnect';?>
</a>
<BR/><BR/>
<a target="_top" href="https://www.musiclassroom.com/membre/changeinfo.php?lang=<?php echo $lang; ?>">
<?php if ($lang=='fr')
echo 'Mon compte / Modifier';
if ($lang=='en')
echo 'My account / Modify';
?>
</a>
</font>
</p>
<BR/><BR/>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="25%">
<p align="center"><b><font color="#274F76" size="5">
<?php
if($lang=='fr') echo 'Cours';
if($lang=='en') echo 'Lessons';
?></font></b></p>
</td>
<td width="25%">
<p align="center"><b><font color="#274F76" size="5">
<?php
if($lang=='fr') echo 'Téléchargements';
if($lang=='en') echo 'Downloads';
?></font></b></p>
</td>
<td width="25%">
<p align="center"><b><font color="#274F76" size="5">
<?php
if($lang=='fr') echo 'Vidéos';
if($lang=='en') echo 'Videos';
?></font></b></p>
</td>
<td width="25%">
<p align="center"><b><font color="#274F76" size="5">Exercices</font></b></p>
</td>
</tr>
<tr>
<td width="25%" align='center' valign='top'>
<p align="center"><font color="#274F76">
<?php if($lang=='fr') echo 'Poursuivez vos cours:';
if($lang=='en') echo 'Continue your lessons:'; ?>
</font><br/><br/>
<?php
//connexion au serveur
//selection de la BD
$req2 = "****";
$reponse2 = mysql_query ($req2);
while($courspayant = mysql_fetch_array($reponse2))
{
echo "<a href='./cours/".$courspayant['LienCoursPayant']."?lang=".$lang."'>".$courspayant['Nom_'.$lang.'_CoursPayant']."</a><BR/><BR/>";
}
mysql_close($linkid);
?>
</td>
<td width="25%" valign='top'>
<p align="center"><font color="#274F76">
<?php if($lang=='fr') echo 'Téléchargez les ebooks:';
if($lang=='en') echo 'Downloads ebooks:'; ?>
</font><br/><br/>
<?php
//connexion au serveur
//selection de la BD
if($lang=='fr') $req3 = "***";
if($lang=='en') $req3 = "***";
$reponse3 = mysql_query ($req3);
while($panier = mysql_fetch_array($reponse3))
{
if ($lang=='fr') $cond = split(' Telechargement',$panier['produit']);
if ($lang=='en') $cond = split(' Download',$panier['produit']);
$req4 = "***";
$reponse4 = mysql_query ($req4);
$cours = mysql_fetch_array($reponse4);
echo "<a href='download2.php?".$cours['LienDownloads']."'>".$cours['FichierDownloads']."</a><BR/><BR/>";
}
mysql_close($linkid);
?>
</td>
<td width="25%" valign='top'>
<p align="center"><font color="#274F76">
<?php if($lang=='fr') echo 'Visionnez les vidéos:';
if($lang=='en') echo 'See the videos:'; ?>
</font><br/><br/>
<?php
//connexion au serveur
//selection de la BD
if($lang=='fr') $req5 = "***";
if($lang=='en') $req5 = "***";
$reponse5 = mysql_query ($req5);
while($panier = mysql_fetch_array($reponse5))
{
if ($lang=='fr') $cond = split(' Vidéo',$panier['produit']);
if ($lang=='en') $cond = split(' Videos',$panier['produit']);
$req6 = "***";
$reponse6 = mysql_query ($req6);
$cours = mysql_fetch_array($reponse6);
echo "<a href='".$cours['classe'.$lang]."'>".$cours['titre2'.$lang]."</a><BR/><BR/>";
}
mysql_close($linkid);
?>
</td>
<td width="25%" valign='top'>
<p align="center"><font color="#274F76">
<?php if($lang=='fr') echo 'Téléchargez les exercices:';
if($lang=='en') echo 'Download the exercices:'; ?>
</font><br/><br/>
<?php
//connexion au serveur
//selection de la BD
$req7 = "***";
$reponse7 = mysql_query ($req7);
while($panier = mysql_fetch_array($reponse7))
{
$cond = split(' Exercices',$panier['produit']);
$req8 = "***";
$reponse8 = mysql_query ($req8);
$cours = mysql_fetch_array($reponse8);
echo "<a href='".$cours['classe'.$lang]."'>".$cours['titre2'.$lang]."</a><BR/><BR/>";
}
mysql_close($linkid);
?>
</td>
</tr>
</table>
</center>
</div>
</td>
</tr>
</table>
</center>
</div>
<BR/><BR/>
<?php
include('../include/menufin.inc');
include('../include/xiti.inc');
include('../include/google.inc');
?>
</div>
</body>
</html>
Comme je n'arrive pas à voir d'après le code, on va suivre le tableau $_SESSION à la trace.
Après authentification, tu as un $_SESSION['panier'] qui est défini mais vide (et non pas Array) au début de l'ajout d'un article. Question : d'où vient ce $_SESSION['panier'], puisque 'panier' n'apparaît pas dans la page d'authentification ? Quelle est la page affichée immédiatement avant l'affichage de ce $_SESSION['panier'] vide ?
Après authentification, tu as un $_SESSION['panier'] qui est défini mais vide (et non pas Array) au début de l'ajout d'un article. Question : d'où vient ce $_SESSION['panier'], puisque 'panier' n'apparaît pas dans la page d'authentification ? Quelle est la page affichée immédiatement avant l'affichage de ce $_SESSION['panier'] vide ?
Mets l'affichage de la variable $_SESSION dans la page livre.php pour voir si $_SESSION['panier'] y est défini sans les LibelleProduit etc..
En remontant de page en page, on finira bien par trouver quand cette variable est créée, et pourquoi elle est incomplète.
En remontant de page en page, on finira bien par trouver quand cette variable est créée, et pourquoi elle est incomplète.
Refais-tu toujours la même manip ? Vu tes symptômes, il faudrait fermer complètement toutes les instances de ton navigateur (et pas seulement un onglet) à chaque fois pour détruire la session et recommencer depuis la page d'accueil du site.
Bonsoir
J'ai compris comment résoudre le problème de façon bricolo!
En fait, la session d'authentification supprimait le panier (à savoir pourquoi...) mais pas l'état créer du panier. Donc lorsque je revenais sur le panier, il croyait que le panier existait et donc il essayait d'y accéder, ce qui générait une erreur évidemment...
J'ai résolu cela en détruisant toute session avant la création de la session d'authentification et cela marche. Seul inconvénient, le visiteur perd son panier à la connexion.
J'ai compris comment résoudre le problème de façon bricolo!
En fait, la session d'authentification supprimait le panier (à savoir pourquoi...) mais pas l'état créer du panier. Donc lorsque je revenais sur le panier, il croyait que le panier existait et donc il essayait d'y accéder, ce qui générait une erreur évidemment...
J'ai résolu cela en détruisant toute session avant la création de la session d'authentification et cela marche. Seul inconvénient, le visiteur perd son panier à la connexion.
la session d'authentification supprimait le panier (à savoir pourquoi...)
Comme tu dis, à savoir pourquoi.
Dans le code de l'authentification que tu montres au message 8, il n'y a rien qui modifie le panier. Il y a quelque chose qui ne se passe pas comme tu crois, et si tu réussis à passer à côté en détruisant toi-même la session, tu ne sais pas si ça ne va pas ressurgir à la prochaine modif.
À mon avis, tu ferais mieux de comprendre ce qui se passait : il suffit d'afficher l'état du panier aux divers endroits ou tu passes pour voir quand il est modifié à ton insu. Ça n'est pas compliqué, et ça permettrait à tes visiteurs de conserver leur panier quand ils s'identifient.
Comme tu dis, à savoir pourquoi.
Dans le code de l'authentification que tu montres au message 8, il n'y a rien qui modifie le panier. Il y a quelque chose qui ne se passe pas comme tu crois, et si tu réussis à passer à côté en détruisant toi-même la session, tu ne sais pas si ça ne va pas ressurgir à la prochaine modif.
À mon avis, tu ferais mieux de comprendre ce qui se passait : il suffit d'afficher l'état du panier aux divers endroits ou tu passes pour voir quand il est modifié à ton insu. Ça n'est pas compliqué, et ça permettrait à tes visiteurs de conserver leur panier quand ils s'identifient.
Merci de ta réponse,
En fait, je pense que le fait de déclarer une session panier écrase ma session d'authentification et vice versa...
Quelqu'un a-t-il une idée pour pouvoir utiliser les deux sessions en même temps?