Aller au contenu
View in the app

A better way to browse. Learn more.

Next

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problème avec mon panier virtuel

Featured Replies

Posté(e)

Bonjour

voila lorsque je rajoute un article dans mon panier il me le rajoute mais ne me met pas tout ce que je lui demande. Voici l'erreur:

Notice: Undefined index: an in C:\Program Files\EasyPHP 2.0b1\www\panieroriginal.php on line 18

et voici mon code:

le panier:

function creationPanier()
{
$ret=false;

if (isset( $_SESSION['panier']))
{
	$ret = true;
} 
else
{
	$_SESSION['panier']=array();
	$_SESSION['panier']['Nom_auteur'] = array();
	$_SESSION['panier']['Titre'] = array();	  
	$_SESSION['panier']['Prix_vente_euro'] = array();
	$_SESSION['panier']['Annee'] = array();	  
	$ret=true;
}
	return $ret;
}

Et le lien pour ajouter l'article au panier:

							<a href=\"panieroriginal.php?action=ajout&au=".$req2['Nom_auteur']."&t=".$req2['Titre']."&p=".$req2['Prix_vente_euro'].";an=".$req2['Annee']."&\" onclick='window.open(this.href, '', 'toolbar=no, location=no, directories=no, status=yes, scrollbars=yes, resizable=yes, copyhistory=no, width=600, height=350'); return false;'>Ajouter au panier</a>

la fonction permettant d'ajouterun article:

function ajouterArticle($Nom_auteur,$Titre,$Prix_vente_euro,$Annee)
{
if (creationPanier())
{
	array_push( $_SESSION['panier']['Nom_auteur'],$Nom_auteur);
	array_push( $_SESSION['panier']['Titre'],$Titre); 
	array_push( $_SESSION['panier']['Prix_vente_euro'],$Prix_vente_euro);
	array_push( $_SESSION['panier']['Annee'],$Annee);	  
}

else
{
	echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}	
}

et j'utilise ca pour ajouter, supprimer ou vider le panier:

if (isset($_GET['action']))
{
if(in_array( $_GET['action'],array('ajout', 'suppression', 'viderPanier', 'supprimerBD')))
{	

	$action = $_GET['action'];
}
switch($action)
{
	Case "ajout":
	$au=preg_replace('#\v#', '',$_GET['au']);
	$t=preg_replace('#\v#', '',$_GET['t']);
	$p=floatval($_GET['p']);
	$an=intval($_GET['an']);
	ajouterArticle($au,$t,$p,$an);
	break;

	Case "suppression":		
	$t=preg_replace('#\v#', '',$_GET['t']);
	supprimerArticle($t);
	break;

	Case "viderPanier":
	viderPanier();
	break;

	Default:
	break;
}
}

Modifié par Ratiche

Posté(e)

Tu peut indiquer dans ton code la ligne mis en question dans l'erreur ? parce qu'on a pas les nom de fichier et les ligne alors on sais pas trop :mdr:

Sinon déja, ta fonction "creationPanier()", si je me trompe pas, elle renvoie toujours "true" non ? donc le if (creationPanier()) sera toujours vrai ...

Posté(e)
  • Auteur

La ligne mis en question est celle-ci: (elle vient du dernier fichier celui ou je rajoute, supprime des articles ou vide le panier)

$an=intval($_GET['an']);

Et oui en effet normalement elle retournera tjs vrai. Et mon if sera tjs vrai oui.

Posté(e)

La solution est la suivante (je suppose) : $_GET['an'] est utilisé sans vérifier qu'il existe ou pas (avec isset()) donc le script est pas content et dit que l'index existe pas

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.