Salve. Ho un problema con la procedura di un
e-commerce in php.
Quando viene fatto l'"aggiungi" al carrello il prodotto viene caricato. Cliccando poi su "check out" si visualizza il file "checkout.php" che include un modulo per inserire i vari dati per postare l'ordine alla e-mail. L'invio di "check out" chiama il file "mail.php" CHE RIPORTERO' DI SEGUITO ALLA SPIEGAZIONE.
In "mail.php" ci sono istruzioni per tre messaggi
possibili visualizzati dall'utente:
1 - "errore il carrello è vuoto" -
(naturalmente avviene quando viene fatta la procedura senza aver caricato il prodotto)
2 - "errore compila tutti i campi" -
(quando non vengono riempiti almeno 3 campi,
in questo caso è presente anche il tasto BACK )
3 - "attendere prego....." seguito da un messaggio
di "andata a buon fine" (con un file html che successivamente viene caricato per azzerare il carrello:view_zero.html)
Tutto ciò in locale mi funziona: LA VERSIONE PHP
SUL MIO PC E': 4.1.1
In rete ricevo sempre e comunque il messaggio
"carrello vuoto". Sia che aggiunga item, sia che
lasci campi vuoti. LA VERSIONE PHP DEL SERVER
E':4.3.11
Non ne so abbastanza di php per vedere velocemente
il problema.
Riporto di seguito il file "mail.php",
cosi' che qualcuno possa vedere cosa non va. Per quanto ne capisco è senza dubbio dovuto alla differente versione. Cosa devo modificare?
Ringrazio e saluto.
--------------------------------------------------
<? include("vars.php"); ?>
<? include("functions.php"); ?>
<?
if (file_exists("header.php"))
include("header.php");
?>
<? dispHeader($categ,$search,$cat); ?>
<table class="tableBackground" width="100%" cellspacing="0" cellpadding="2">
<tr>
<td><font class="titleFont">[b]Cassa - Check Out</font></td>
</tr>
</table>
<?
$numitems = sizeof($item);
if ($numitems == 0) {
?>
Errore - Error!
Il tuo carrello è vuoto - There are no items in your cart.
<?
}
else {
if ($contactname == "" || $billing_adr == "" || $delivery_adr == "" || $email == "") {
?>
Errore - Error
Per favore torna indietro completa tutti i campi - Please go back and complete all the fields.
<form><input type="hidden" name="clear" value="Indietro - Back " onclick="java script:history.go(-1);">
<center>[img]indietro_carrello.gif[/img]</center>
<?
}
else {
for ($i=0;$i<$numitems;$i++) {
$items .= "$item[$i] x $quantity[$i] @ $priceeach[$i] each = $totalcost[$i]\n";
$subtotal += $totalcost[$i];
}
$total = $subtotal + $tax_calc + $freightop + $ex_am;
$subtotal = number_format("$subtotal",2);
$tax_calc = number_format("$tax_calc",2);
$freightop = number_format("$freightop",2);
$ex_am = number_format("$ex_am",2);
$total = number_format("$total",2);
$body .="Items Ordered:\n\n";
$body .="$items\n\n";
$body .="Sub Total.... $subtotal\n";
$body .="$tax_name............. $tax_calc\n";
$body .="Freight........ $freightop\n";
$body .="Extra........... $ex_am\n";
$body .="Total........... $total\n\n";
$body .="Delivery Details:\n\n";
$body .="Contact Name: $contactname\n";
$body .="Billing Address: $billing_adr\n";
$body .="Delivery Address: $delivery_adr\n";
$body .="Email: $email\n";
$body .="TELEFONO Phone: $phone\n\n";
$body .="Payment Details:\n\n";
$body .="Payment Type: $paytype\n";
$body .="Credit Card No.: $ccno\n";
$body .="Expiry Date: $ccexp\n";
$body .="Name on Card: $noc\n";
$to = "$order_email";
$from = "Web Shop Manager <$order_email>";
$subject = "Web Store Order";
if ($pgpuser != "") {
$tmpfname = tempnam("/tmp","pgpfm").".asc";
putenv("PGPPATH=/home/nobody/.pgp");
$pp = popen("/usr/bin/pgpe -r \"$pgpuser\" -a -o $tmpfname","w");
fputs($pp,$body);
pclose($pp);
$body = trim(implode(file($tmpfname),""));
unlink($tmpfname);
}
mail($to,$subject,$body,"FROM: ".$from);
echo "
attendere prego...... - wait please......";
echo "<meta http-equiv=\"Refresh\" content=\"3; URL=http://www.mondovinile.net/view_zero.html\" >";
}
}
?>
<hr width="100%" size="1" noshade color="ff7700">
<? dispFooter(); ?>
<?
if (file_exists("footer.php"))
include("footer.php");
?>