The Way to Programming
The Way to Programming
I’m a beginner learning php and have made a calculation script, but seems like I have made a mistake somewhere in my calculations…
Index.php (Input Form)
It seems to work perfectly…
gc.php (calculations)
$im = 120; $dm = 200; $cm = 1000; $bom = 2000; $bm = 3650; <---Crystal---> $ic = 80; $dc = 160; $cc = 540; $boc = 840; $bc = 1900; <---Gas---> $ig = 120; $dg = 150; $cg = 1360; $bog = 1450; $bg = 4970; <---Attack HP---> $ia = 80; $da = 44; $ca = 300; $boa = 50; $ba = 1400; <---Defence HP---> $id = 20; $dd = 110; $cd = 450; $bod = 10; $bd = 1180; <---Total Attack HP - Ship Type---> $tia = ($_GET["inter"] * $ia); $tda = ($_GET["destr"] * $da); $tca = ($_GET["cruiser"] * $ca); $tboa = ($_GET["bomb"] * $boa); $tba = ($_GET["battle"] * $ba); <---Total Defence HP - Ship Type---> $tid = ($_GET["inter"] * $id); $tdd = ($_GET["destr"] * $dd); $tcd = ($_GET["cruiser"] * $cd); $tbod = ($_GET["bomb"] * $bod); $tbd = ($_GET["battle"] * $bd); <---Total Attack---> $tatt - ($tia + $tda + $tca + $tboa + $tba); <---Total Defence---> $tdef = ($tid + $tdd + $tcd + $tbod + $tbd); <---Total Troops---> $ttroops = ($_GET["inter"] + $_GET["destr"] + $_GET["cruiser"] $_GET["bomb"] + $_GET["battle"] );
Troops | Amount | Attack HP | Defence HP |
Interceptors | |||
Destroyers | |||
Cruisers | |||
Bombers | |||
Battleships | |||
Totals |
Seems like I have made few mistakes somewhere and I can’t seem to find it can anybody please assist?
You need to decide whether you are going to use POST or GET and use the same in your form and processing.
you are using method=”post” in your form, and yet all of your php processing is using $_GET.
method=”post” requires you to use $_POST[] in your processing…and method=”get” requires you to use $_GET[] in your processing.
POST doesn’t know anything about GET and vice versa.
Sign in to your account