Bonjour et bonnes fêtes!
je construis une boutique en ligne, mon panier fonctionne parfaitement en local, et pas du tout sur le site distant.Quelles pourraient en être les raisons?
Et comment y remédier?
je constate aussi des incohérences sur différents codes.
J'utilise, vista ultimate, wamp, php 5.29.1 mon hébergeur est 1&1.fr
j'en profite pour vous remercier, a chaque fois que j'ai demandé de l'aide sur votre forum, j'ai obtenu une réponse efficace et cohérente à mon problème, ce qui est rare!
voici les pages de codes concernées:
//fichier qui affiche le panier
<?php
session_start();
include("fonctionPanier.php");
?>
<!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" xml:lang="fr" >
<head>
<title>Votre commande</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" media="screen" type="text/css" title="commande de séminaire yoga" href="ecun2.css" /><!--Fichier C.S.S.-->
</head>
<body>
<table style="width:400px">
<tr>
<td colspan="4">Votre commande</td>
</tr>
<tr>
<td>Nom</td><td>Quantité</td><td>Prix unitaire</td><td>Total partiel</td>
</tr>
<?php
if(creationPanier())
{
$nbArticles = count($_SESSION['panier']['article']);
if($nbArticles <= 0)
echo "<tr><td>Votre panier est vide</td><td></td></tr>";
else
{
for( $i = 0 ; $i < $nbArticles ; $i++)
{
$a = $_SESSION['panier']['article'][$i];
$p = $_SESSION['panier']['qte'][$i]*$_SESSION['panier']['prix'][$i];
echo"<tr>";
echo"<td>".$_SESSION['panier']['article'][$i]."</td>";
echo"<td>".$_SESSION['panier']['qte'][$i]."</td>";
echo"<td>".$_SESSION['panier']['prix'][$i]."</td>";
echo"<td>".$p."</td>";
echo"</tr>";
}
}
echo "<tr><td colspan=\"2\"> </td>";
echo "<td colspan=\"2\">";
echo "Montant global : ".MontantGlobal();
echo "</td></tr>";
}
?>
</table><br />
<form method="POST" action="enregistrement.php">
<p>
<?php
if(creationPanier())
{
$nbArticles = count($_SESSION['panier']['article']);
if($nbArticles <= 0)
echo "Votre panier est vide";
else
{
for( $i = 0 ; $i < $nbArticles ; $i++)
{
$numero = time();
$n = $_SESSION['panier']['article'][$i];
$q = $_SESSION['panier']['qte'][$i];
$pr = $_SESSION['panier']['prix'][$i];
$mg = MontantGlobal();
$p = $_SESSION['panier']['qte'][$i]*$_SESSION['panier']['prix'][$i];
echo"
<input type=\"hidden\" name=\"nomcom\" value=\".$n.\">
<input type=\"hidden\" name=\"qtecom\" value=\".$q.\">
<input type=\"hidden\" name=\"prixcom\" value=\".$pr.\"><br />";
}
}
echo "<input type=\"hidden\" name=\"montglobcom\" value=".$mg."><br />";
}
?>
<h2>Vérifiez vos coordonnées et validez votre commandeS.V.P.</h2><br />
<label for="numero">le N° de votre commande est:</label><input type="text" name="numero" value="<?php echo $numero ;?>"/>
<label for="pseudo">Votre pseudo: </label><input type="text" name="pseudo" id="pseudo"value="<?php echo $_SESSION['pseudo'];?>"/><br />
<label for="password">Votre mot de passe: </label><input type="password" name="password" id="password"value="<?php echo $_SESSION['password'];?>"/>
<label for="password2">Répétez votre mot de passe: </label><input type="password" name="password2"
id="password2"value="<?php echo $_SESSION['password2'];?>"/><br />
<label for="civilite">Civilité: </label>
<select name="civilite" id="civilite"value="<?php echo $_SESSION['civilite'];?>"/>
<option value="Mme">Madame</option>
<option value="Mlle">Mademoiselle</option>
<option value="Mr">Monsieur</option>
</select>
<label for="nom">Votre nom: </label><input type="text" name="nom" id="nom"size="30"value="<?php echo $_SESSION['nom'];?>"/>
<label for="prenom">Votre prénom: </label><input type="text" name="prenom" id="prénom"size="15"value="<?php echo $_SESSION['prenom'];?>"/><br />
<label for="adresse">Votre adresse: </label><input type="text" name="adresse" id="adresse"size="50"value="<?php echo $_SESSION['adresse'];?>"/>
<label for="pays">Pays: </label><input type="text" name="pays" id="pays"size="15"value="<?php echo $_SESSION['pays'];?>"/>
<label for="ville">Ville: </label><input type="text" name="ville" id="ville"size="15"value="<?php echo $_SESSION['ville'];?>"/><br />
<label for="cp">Votre code postal: </label><input type="text" name="cp" id="cp"size="5"value="<?php echo $_SESSION['cp'];?>"/>
<label for="mail">Votre mail: </label><input type="text" name="mail" id="mail"size="30"value="<?php echo $_SESSION['mail'];?>"/>
<label for="tel">Votre Tel.: </label><input type="text" name="tel" id="tel"size="10"value="<?php echo $_SESSION['tel'];?>"/><br />
<label>Je me suis trompé, je recommence: </label><input type="reset" value="reinitialiser"/><br /><br />
<input type="submit" value=" je confirme la commande et procéde au paiment"/>
</p>
</form>
</body>
</html>
//fonctions du panier
<?php
function creationPanier()
{
$ret = false;
if(isset($_SESSION['panier']))
$ret = true;
else
{
$_SESSION['panier'] = array();
$_SESSION['panier']['article'] = array();
$_SESSION['panier']['qte'] = array();
$_SESSION['panier']['prix'] = array();
$ret = true;
}
return $ret;
}
//--------------------------------AJOUT-------------------------------------------------------------------------
function ajout($article, $qte, $prix)
{
if(creationPanier())
{
$position = array_search($article, $_SESSION['panier']['article']);
if($position !== false)
{
$_SESSION['panier']['qte'][$position] += $qte;
}
else
{
array_push($_SESSION['panier']['article'], $article);
array_push($_SESSION['panier']['qte'], $qte);
array_push($_SESSION['panier']['prix'], $prix);
}
}
else
{
echo'Ta 1 blème, mon pote!';
}
}
//supprimer
function supprimer($article){
if (creationPanier())
{
$tmp=array();
$tmp['article'] = array();
$tmp['qte'] = array();
$tmp['prix'] = array();
for($i = 0; $i < count($_SESSION['panier']['article']); $i++)
{
if ($_SESSION['panier']['article'][$i] !== $article)
{
array_push( $tmp['article'],$_SESSION['panier']['article'][$i]);
array_push( $tmp['qte'],$_SESSION['panier']['qte'][$i]);
array_push( $tmp['prix'],$_SESSION['panier']['prix'][$i]);
}
}
$_SESSION['panier'] = $tmp;
unset($tmp);
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
// total ------>
function MontantGlobal(){
$total=0;
for($i = 0; $i < count($_SESSION['panier']['article']); $i++)
{
$total += $_SESSION['panier']['qte'][$i] * $_SESSION['panier']['prix'][$i];
}
return $total;
}
//------------------------------------------------------------------------------MODIFIER
function modifierQteArticle($article,$qte){
if (creationPanier())
{
if ($qte > 0)
{
$position = array_search($article, $_SESSION['panier']['article']);
if ($position !== false)
{
$_SESSION['panier']['qte'][$position] = $qte ;
}
}
else
supprimer($article);
}
else
echo "Un problème est survenu veuillez contacter l'administrateur du site.";
}
?>