I have been searching around for the solution for so long, but every time the person who asked the question is way higher than my level. I'm only a young beginner, and I can't find anything that could ever solve my problem. Every PHP-Checker says my code is fine, but here is the problem:
I put an Echo in my If-Else Statement, but without any errors, or syntax problems, the Echo'd Text simply does not display on my site.
Now, I don't know what to do. But I'd like to ask anyone reading this to Pretend I'm Five years old and keep it simple, because I can't figure it out. I don't use SQL or any weird trickery as far as I know, and this is part of my school project, so it should be possible to do very simply.
The Code:
<form action='' method='post'>
<table>
<tr>
<td> banana: </td>
<td><input type='text' name='product1' /></td>
</tr>
<tr>
<td> candy: </td>
<td><input type='text' name='product2' /></td>
</tr>
<tr>
<td> tv: </td>
<td><input type='text' name='product3' /></td>
</tr>
<tr>
<td> mouse: </td>
<td><input type='text' name='product4' /></td>
</tr>
<tr>
<td><input type='submit' value='submit' /></td>
</tr>
</table>
</form>
<?php
if (isset($_POST['submit'])) {
$iProductammount1 = $_POST['product1'];
$iProductammount2 = $_POST['product2'];
$iProductammount3 = $_POST['product3'];
$iProductammount4 = $_POST['product4'];
$fprice1 = 5.00;
$fprice2 = 0.99;
$fprice3 = 200.00;
$fprice4 = 15.00;
$fProductprice1 = $iProductammount1*$fprice1;
$fProductprice2 = $iProductammount2*$fprice2;
$fProductprice3 = $iProductammount3*$fprice3;
$fProductprice4 = $iProductammount4*$fprice4;
$fTotal = $fProductprice1+$fProductprice2+$fProductprice3+$fProductprice4;
if ($fTotal > 250) {
$fDiscountprice = $fTotal*0.85;
$sDiscount = '15%';
} else if ($fTotal > 100 ) {
$fDiscountprice = $fTotal*0.90;
$sDiscount= '10%';
} else {
$fDiscountprice = $fTotal;
$sDiscount= '0%';
}
echo "The usual price is € ".number_format($fTotal,2,',','.').". You received a discount of ".$sDiscount." . The new price is € ".number_format($fDiscountprice,2,',','.');
} else {
}
?>
I used "isset" to only do all of this when the button "submit" is pressed, which does seem to work, since putting an Echo in between the Else brackets does actually Echo it properly. However, the Echo at the end of the If-statement does not show up at all. After pressing submit, simply nothing happens at all. The numbers filled in the disappear, and you can start all over again.
I'd also like to mention that there is a tag and all the necessary things above this, but I didn't feel like they were worth mentioning.
Again, the point of interest is the final Echo line at the end of the code. Please help me figure this out!
Explain to me like I'm 5, thanks for reading :)