ma è quello che ho fatto, però non conoscendo bene, anzi molto male, il php non riesco a capire dove sia il problema.
Per questo ho chiesto aiuto a voi esperti!
Per questo ho chiesto aiuto a voi esperti!
<?php
/*
Page : panier_valider.php
Page qui envoie et confirme la commande
*/
$NumeroCommande = date("Gisdm")." - ".date("y");
$TotalCommande = 0;
//On regarde si le paramètre sont correcte
if (isset($_SESSION["commande"]["prod"])){
if (isset($_POST["tnom"]) && isset($_POST["ttel"])){
$headers ='From: "Au petit comestible"<webmaster@aupetitcomestible.net>'."\n";
$headers .='Content-Type: text/html; charset="iso-8859-1"'."\n";
$headers .='Content-Transfer-Encoding: 8bit';
$cles = array_keys($_SESSION["commande"]["prod"]);
if (isset($_POST["tremarques"]))
$remarques = $_POST["tremarques"];
else
$remarques = 'Aucune.';
//Numéro de commande : '.$NumeroCommande.'<br />
$messageclients = '<html>
<head>
<title>
Votre Commande
</title>
</head>
<body>
<p>Bonjour '.$_POST["tnom"].', votre commande a bien été prise en compte : <br /><br />
Téléphone : '.$_POST["ttel"].'<br />
Heure de passage : '.$_POST["theureh"].'h'.$_POST["theurem"].'<br/>
</p>
<table width="600">
<caption style="font-size:20px;color:#000000;font-weight:bold;">Commande</caption>
<tr>
<th style="background:#FFFFFF;color:#000000;">Produit</th>
<th style="background:#FFFFFF;color:#000000;">Prix</th>
<th style="background:#FFFFFF;color:#000000;">Quantité</th>
<th style="background:#FFFFFF;color:#000000;">Sous total</th>
</tr> ';
$tot = 0;
foreach($cles as $i){
if (array_key_exists($i, $_SESSION["commande"]["prod"]))
{
$_SESSION["commande"]["prix"][$i] = str_replace(",", ".", $_SESSION["commande"]["prix"][$i]);
$soustot = (float)$_SESSION["commande"]["prix"][$i] * (float)$_SESSION["commande"]["quantite"][$i];
$_SESSION["commande"]["prix"][$i] = str_replace(".", ",", $_SESSION["commande"]["prix"][$i]);
$messageclients .= '<tr>
<td style="border:#000000 solid 1px;">
'.stripslashes($_SESSION["commande"]["prod"][$i]).'
</td>
<td style="text-align:right;border:#000000 solid 1px;">
'.$_SESSION["commande"]["prix"][$i].' CHF
</td>
<td style="text-align:center;border:#000000 solid 1px;">
'.$_SESSION["commande"]["quantite"][$i].'
</td>
<td style="text-align:right;border:#000000 solid 1px;">
'.number_format($soustot, 2, ',', ' ').' CHF
</td>
</tr>';
$tot += $soustot;
}
}
$messageclients .= '</table><div style="text-align:right;margin-top:10px;width:600px;color:#000000;font-size:18px;">
Total : '.number_format($tot, 2, ',', ' ').' CHF</div>
<br /><br />
Remarques : '.$remarques.'
</body></html>';
//Numéro de commande : '.$NumeroCommande.'<br />
$message = '<html>
<head>
<title>
Nouvelle commande
</title>
</head>
<body>
<p>
Nom : '.$_POST["tnom"].'<br />
Téléphone : '.$_POST["ttel"].'<br />
Email : '.$_POST["tmail"].'<br >
Heure de passage : '.$_POST["theureh"].'h'.$_POST["theurem"].'<br/>
Remarques : '.$remarques.' <br />
</p>
<table width="600">
<caption style="font-size:20px;color:#000000;font-weight:bold;">Commande</caption>
<tr>
<th style="background:#FFFFFF;color:#000000;font-size:12px;">Quantité</th>
<th style="background:#FFFFFF;color:#000000;font-size:12px;">Produit</th>
<th style="background:#FFFFFF;color:#000000;font-size:12px;">Prix</th>
<th style="background:#FFFFFF;color:#000000;font-size:12px;">Sous total</th>
</tr>';
$tot = 0;
foreach($cles as $i){
if (array_key_exists($i, $_SESSION["commande"]["prod"]))
{
$_SESSION["commande"]["prix"][$i] = str_replace(",", ".", $_SESSION["commande"]["prix"][$i]);
$soustot = (float)$_SESSION["commande"]["prix"][$i] * (float)$_SESSION["commande"]["quantite"][$i];
$_SESSION["commande"]["prix"][$i] = str_replace(".", ",", $_SESSION["commande"]["prix"][$i]);
$message .= '<tr>
<td style="border:#000000 solid 1px;text-align:center;">
'.$_SESSION["commande"]["quantite"][$i].'
</td>
<td style="border:#000000 solid 1px;">
'.stripslashes($_SESSION["commande"]["prod"][$i]).'
</td>
<td style="text-align:right;border:#000000 solid 1px;">
'.$_SESSION["commande"]["prix"][$i].' .Sfr
</td>
<td style="text-align:right;border:#000000 solid 1px;">
'.number_format($soustot, 2, ',', ' ').' CHF
</td>
</tr>';
$tot += $soustot;
}
}
$message .= '</table><div style="text-align:right;margin-top:10px;width:600px;color:#000000;font-size:18px;">
Total : '.number_format($tot, 2, ',', ' ').' CHF</div></body></html>';
$mail = $params["mail"];
if(@mail($mail, 'Commande Au petit comestible', $message, $headers) && @mail($_POST["tmail"], 'Commande Au petit comestible', $messageclients, $headers))
{
echo '<br />Commande envoyée! Un Email de confirmation a été envoyé à l\'adresse : '.$_POST["tmail"].'.<div class="spa"></div>';
$sqlcommande = "INSERT INTO tstat (idstat, datecommande, champtype, description, prix) VALUES ";
foreach($cles as $i)
{
if (array_key_exists($i, $_SESSION["commande"]["type"]) && $_SESSION["commande"]["type"] != NULL)
{
for ($j = 0; $j < $_SESSION["commande"]["quantite"][$i]; $j++)
{
$desc = str_replace("<br />", " - ", $_SESSION["commande"]["prod"][$i]);
$desc = strip_tags($desc);
$sqlcommande .= " ('', '".date("Y-m-d")."', '".$_SESSION["commande"]["type"][$i]."', '".addslashes($desc)."',".number_format((float)$_SESSION["commande"]["prix"][$i], 2, '.', ' ').")";
}
}
}
$sqlcommande = substr($sqlcommande, 0, strlen($sqlcommande)-1);
$sqlcommande .= ";";
mysql_query($sqlcommande) or die ("Erreur SQL > ".$sqlcommande."<br />".mysql_error());
unset($_SESSION["commande"]);
}
else
echo '<br />Erreur répéter l\'opération.<div class="spa"></div>';
}
}
?>
<?php
/*
Page : panier_valider.php
Page qui envoie et confirme la commande
*/
$NumeroCommande = date("Gisdm")." - ".date("y");
$TotalCommande = 0;
//On regarde si le paramètre sont correcte
if (isset($_SESSION["commande"]["prod"])){
if (isset($_POST["tnom"]) && isset($_POST["ttel"])){
$headers ='From: "Au petit comestible"<webmaster@aupetitcomestible.net>'."\n";
$headers .='Content-Type: text/html; charset="iso-8859-1"'."\n";
$headers .='Content-Transfer-Encoding: 8bit';
$cles = array_keys($_SESSION["commande"]["prod"]);
if (isset($_POST["tremarques"]))
$remarques = $_POST["tremarques"];
else
$remarques = 'Aucune.';
//Numéro de commande : '.$NumeroCommande.'<br />
$messageclients = '<html>
<head>
<title>
Votre Commande
</title>
</head>
<body>
<p>Bonjour '.$_POST["tnom"].', votre commande a bien été prise en compte : <br /><br />
Téléphone : '.$_POST["ttel"].'<br />
Heure de passage : '.$_POST["theureh"].'h'.$_POST["theurem"].'<br/>
</p>
<table width="600">
<caption style="font-size:20px;color:#000000;font-weight:bold;">Commande</caption>
<tr>
<th style="background:#FFFFFF;color:#000000;">Produit</th>
<th style="background:#FFFFFF;color:#000000;">Prix</th>
<th style="background:#FFFFFF;color:#000000;">Quantité</th>
<th style="background:#FFFFFF;color:#000000;">Sous total</th>
</tr> ';
$tot = 0;
foreach($cles as $i){
if (array_key_exists($i, $_SESSION["commande"]["prod"]))
{
$_SESSION["commande"]["prix"][$i] = str_replace(",", ".", $_SESSION["commande"]["prix"][$i]);
$soustot = (float)$_SESSION["commande"]["prix"][$i] * (float)$_SESSION["commande"]["quantite"][$i];
$messageclients .= '<tr>
<td style="border:#000000 solid 1px;">
'.stripslashes($_SESSION["commande"]["prod"][$i]).'
</td>
<td style="text-align:right;border:#000000 solid 1px;">
'.$_SESSION["commande"]["prix"][$i].' CHF
</td>
<td style="text-align:center;border:#000000 solid 1px;">
'.$_SESSION["commande"]["quantite"][$i].'
</td>
<td style="text-align:right;border:#000000 solid 1px;">
'.number_format($soustot, 2, ',', ' ').' CHF
</td>
</tr>';
$tot += $soustot;
}
}
$messageclients .= '</table><div style="text-align:right;margin-top:10px;width:600px;color:#000000;font-size:18px;">
Total : '.number_format($tot, 2, ',', ' ').' CHF</div>
<br /><br />
Remarques : '.$remarques.'
</body></html>';
//Numéro de commande : '.$NumeroCommande.'<br />
$message = '<html>
<head>
<title>
Nouvelle commande
</title>
</head>
<body>
<p>
Nom : '.$_POST["tnom"].'<br />
Téléphone : '.$_POST["ttel"].'<br />
Email : '.$_POST["tmail"].'<br >
Heure de passage : '.$_POST["theureh"].'h'.$_POST["theurem"].'<br/>
Remarques : '.$remarques.' <br />
</p>
<table width="600">
<caption style="font-size:20px;color:#000000;font-weight:bold;">Commande</caption>
<tr>
<th style="background:#FFFFFF;color:#000000;font-size:12px;">Quantité</th>
<th style="background:#FFFFFF;color:#000000;font-size:12px;">Produit</th>
<th style="background:#FFFFFF;color:#000000;font-size:12px;">Prix</th>
<th style="background:#FFFFFF;color:#000000;font-size:12px;">Sous total</th>
</tr>';
$tot = 0;
foreach($cles as $i){
if (array_key_exists($i, $_SESSION["commande"]["prod"]))
{
$_SESSION["commande"]["prix"][$i] = str_replace(",", ".", $_SESSION["commande"]["prix"][$i]);
$soustot = (float)$_SESSION["commande"]["prix"][$i] * (float)$_SESSION["commande"]["quantite"][$i];
//$_SESSION["commande"]["prix"][$i] = str_replace(".", ",", $_SESSION["commande"]["prix"][$i]);//
$message .= '<tr>
<td style="border:#000000 solid 1px;text-align:center;">
'.$_SESSION["commande"]["quantite"][$i].'
</td>
<td style="border:#000000 solid 1px;">
'.stripslashes($_SESSION["commande"]["prod"][$i]).'
</td>
<td style="text-align:right;border:#000000 solid 1px;">
'.$_SESSION["commande"]["prix"][$i].'
</td>
<td style="text-align:right;border:#000000 solid 1px;">
'.number_format($soustot, 2, ',', ' ').' CHF
</td>
</tr>';
$tot += $soustot;
}
}
$message .= '</table><div style="text-align:right;margin-top:10px;width:600px;color:#000000;font-size:18px;">
Total : '.number_format($tot, 2, ',', ' ').' CHF</div></body></html>';
$mail = $params["mail"];
if(@mail($mail, 'Commande Au petit comestible', $message, $headers) && @mail($_POST["tmail"], 'Commande Au petit comestible', $messageclients, $headers));
{
echo '<br /><div style="text-align:center;margin-top:10px;width:650px;color:#4b4c38;font-size:18px;"><b>Commande envoyée!</b><br /> Un e-mail de confirmation a été envoyé à l\'adresse :<br /><br /><i> '.$_POST["tmail"].'</i></div>';
echo
'<div class="paypal">
<p>Si vous souhaitez payer à l\'avance par carte de crédit, cliquez ici:</p>
<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="malerba@aupetitcomestible.net">
<input type="hidden" name="lc" value="CH">
<input type="hidden" name="item_name" value="Commande">
<input type="hidden" name="amount" value="'.$tot.'">
<input type="hidden" name="currency_code" value="CHF">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="add" value="1">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_LG.gif:NonHostedGuest">
<input type="image" src="https://www.paypalobjects.com/fr_FR/CH/i/btn/btn_paynowCC_LG.gif" border="0" name="submit" alt="PayPal - la solution de paiement en ligne la plus simple et la plus sécurisée !">
<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
</form>
<br />
<br />
<br />
<div class="iscrizione2">
<table>
<tr><td><img src="Images/Design/news.png"></td>
<td>
<form action="http://admin.infomaniak.com/mail/mailinglist_process.php" method="POST">
<b>Inscrivez-vous</b> gratuitement à notre news-letter pour recevoir les actualités de la semaine!<br />
Insérez votre adresse e-mail ici:
<input type="hidden" name="maillist" value="bmV3c2xldHRlckBhdXBldGl0Y29tZXN0aWJsZS5uZXQ=">
<input type="text" name="email">
<input type="hidden" name="action" value="add">
<input type="hidden" name="url" value="http://aupetitcomestible.net/iscrizione.html">
<input type="submit" name="add" value="Inscription">
</form></td></tr>
</table>
</div></div>';
}
/* STATISTICHE */
$sqlcommande = "INSERT INTO tstat (idstat, datecommande, champtype, description, prix) VALUES( ";
foreach($cles as $i)
{
if (array_key_exists($i, $_SESSION["commande"]["type"]) && $_SESSION["commande"]["type"] != NULL)
{
for ($j = 0; $j < $_SESSION["commande"]["quantite"][$i]; $j++)
{
$desc = str_replace("<br />", " - ", $_SESSION["commande"]["prod"][$i]);
$desc = strip_tags($desc);
$sqlcommande .= "'', '".date("Y-m-d")."', '".$_SESSION["commande"]["type"][$i]."', '".addslashes($desc)."',".$_SESSION["commande"]["prix"][$i]."'";
}
}
}
$sqlcommande = substr($sqlcommande, 0, strlen($sqlcommande)-1);
$sqlcommande .= ");";
mysql_query($sqlcommande) or die ("Erreur SQL > ".$sqlcommande."<br />".mysql_error());
unset($_SESSION["commande"]);
/* FINE STATISTICHE */
}
else
echo '<br />Erreur répéter l\'opération.<div class="spa"></div>';
}
?>
for ($j = 0; $j < $_SESSION["commande"]["quantite"][$i]; $j++);
foreach ($cles as $i) {
$sqlcommande = "INSERT INTO tstat (idstat, datecommande, champtype, description, prix) VALUES( ";