Buongiorno
ho fatto i due file, uno con il form e l'altro con la funzione php che dovrebbe restituirmi la somma in base ai prodotti scelti e invece mi restituisce sempre il valore iniziale di $tot iniziale.
Qualcuno sa darmi una mano
codice:
<form action="conto.php" method="get">
Primi:
<input type="checkbox" name="p1"> Pizza Margherita
<input type="checkbox" name="p2"> Pizza Marinara
<input type="checkbox" name="p3"> Pizza Capricciosa
<input type="checkbox" name="p4"> Pizza Napoletana
<input type="checkbox" name="p5"> Pizza Bufala
Seconti:
<input type="checkbox" name="s1"> Pesce
<input type="checkbox" name="s2"> Carne
<input type="checkbox" name="s3"> Mozzarella
<input type="checkbox" name="s4"> Affettati
<input type="checkbox" name="s5"> Arrosto
<input type="submit" value="Invia Ordinazione">
</form>
Codice PHP:
<?php
$tot = 3.5;
if ($p1=="on") {
$tot = $tot + 2.5;
}
if ($p2=="on") {
$tot = $tot + 1.5;
}
if ($p3=="on") {
$tot = $tot + 15.5;
}
if ($p4=="on") {
$tot = $tot + 10.5;
}
if ($p5=="on") {
$tot = $tot + 8.5;
}
if ($s1=="on") {
$tot = $tot + 7.5;
}
if ($s2=="on") {
$tot = $tot + 3.5;
}
if ($s3=="on") {
$tot = $tot + 4.5;
}
if ($s4=="on") {
$tot = $tot + 4;
}
if ($s5=="on") {
$tot = $tot + 5;
}
echo "TOTALE = Euro ".$tot."
";
echo "Tornate a trovarci";
?>