Après un gros weekend de prise de tête, je reprend mon site à zero et ne m'occupe que de la structure (comtpe client, panier etc..)
Mais un problème m'agace :
Je réalise actuellement mon Panier d'achat, mais lorsque j'envois le client sur la page panier.php, les informations concernant le produit qu'il a choisi ne s'affichent pas !
Voilà le code php de ma page panier.php, situé ds le même dossier que tous les autres fichiers.
<?php session_start(); ?>
<?php require('/Connections/shop.php'); ?>
<?php
if (!isset($_SESSION)) {
session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserName)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($UserName, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($UserGroup, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoTo = "Login_wrong.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
header("Location: ". $MM_restrictGoTo);
exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$paramclient_panier = "0";
if (isset($_SESSION['MM_Username'])) {
$paramclient_panier = $_SESSION['MM_Username'];
}
mysql_select_db($database_shop, $shop);
$query_panier = sprintf("SELECT shop_panier.*, shop_tshirt.nom, shop_tshirt.prix, (shop_tshirt.prix*shop_panier.quantite) AS total FROM shop_panier INNER JOIN shop_tshirt ON shop_panier.article=shop_tshirt.id WHERE client = %s", GetSQLValueString($paramclient_panier, "text"));
$panier = mysql_query($query_panier, $shop) or die(mysql_error());
$row_panier = mysql_fetch_assoc($panier);
$totalRows_panier = mysql_num_rows($panier);
?>
<pre>
<?php
print_r($_SESSION);
?>
</pre>
<pre>
<?php
print_r($_COOKIE);
?>
</pre>
<pre>
<?php
print_r($_GET);
?>
</pre>
<pre>
<?php
print_r($_POST);
?>
</pre>
<table width="700" border="1">
<tr>
<td><?php echo $row_panier['nom']; ?></td>
<td><?php echo $row_panier['prix']; ?></td>
<td><?php echo $row_panier['quantite']; ?></td>
<td><?php echo $row_panier['total']; ?></td>
</tr>
</table>
<?php echo $row_panier['id']; ?> <?php echo $row_panier['client']; ?>
<?php
mysql_free_result($panier);
?>
Pour que vous me compreniez, voici le screenshot de l'affichage de panier.php après avoir choisi un article (tshirt) :rah je n'arrive pas à upload la photo...grrr Mais en gros:
Il apparait le tableau que jai crée mais vide,dans ce tableau, j'ai fais glisser les données telles que prix, quantite, etc, du jeux d'enregistrement panier
Pensez vous que l'erreur viennes de la variable paramclient ?
Quand j'interroge les globales, la page panier.php m'indique qu'elle a compris que c'est la personne [email protected] qui veut acheter l'article dont l'id = 1
Alors je ne comprend pas...
Ou est ce que mes variables de sessions se sont effacées quelque part ?
Voici la configuration de mon jeu d'enregistrement(panier):
SELECT shop_panier.*, shop_tshirt.nom, shop_tshirt.prix, (shop_tshirt.prix*shop_panier.quantite) AS total
FROM shop_panier INNER JOIN shop_tshirt ON shop_panier.article=shop_tshirt.id
WHERE client = paramclient
ou paramclient est une variable text à valeur par défaut 0 et valeur : $_SESSION['MM_Username']merci pour toute aide de votre part et sachez que je reste debutant sur ce type de codage