Hi all, I hope you can point me in the right direction. I have just started learning PHP, I apologise in advance for a) bad code b) possibly wrong code. I am trying to achieve the following: I have a set of variables in the first part of my code. The user selects some of these variables and presses the 'calculate' button. Using the POST method, these variables are sent to the second part of my code, which does the calculation, and prints something like 'Total cost based upon (variables selected) is:'. The results are printed on the same page (I am posting to the same page). My question is this: How can I prevent the text about the calculation (e.g. 'Total cost based upon 'etc.) appearing when the user first logs onto the page. I only want the text to appear once the user has pressed the calculate button. Am I correct in thinking that I need an IF statement? I cannot use
if ($page = "1") {
echo ("blah blah")
}
as the first lines of the rest of my code goes straight into the calculation:
if ($hosting == $bronze) {
echo ("$bronzeH ");
} elseif ($hosting == $silver) {
echo ("$silverH ");
} elseif ($hosting == $gold) {
echo ("$goldH ");
}
if ($design == $simple) {
echo ("and $simpleD costs ");
} else {
echo ("and $advancedD costs ");
}
echo ($hosting + $design);
Effectively, I wish to know how I can use an IF statement to execute the above code (if $page = "1"). Perhaps I'm barking up the wrong tree. I would appreciate some pointers/advice. Many thanks in advane.
FYI:
$silver = 15.00;
$silverH= "Silver hosting";
$bronze = 10.00;
$bronzeH = "Bronze hosting";
$gold = 50.00;
$goldH = "Gold hosting";
$simple = 30.00;
$simpleD = "Simple design";
$advanced = 100.00;
$advancedD = "Advanced design";