OK, I changed a few things and now I reckon I'm on the way to getting this right. The only thing wrong now, is that it doesn't pass the price on to the next form. I got it right to display the items you chose, but the prices don't go through.
My script now looks like this:
//blah blah blah
session_register("usr", "pwd", "a", "item[]", "price[]");
//irrelavant code
{
$a = 1;
echo "<form method=post>
Select the items you want<br><br>";
$f = file($afile);
foreach ($f as $key=>$val)
{
$entry = explode(",",$val);
foreach ($entry as $key2=>$val2)
{
$tmp=explode("-",$val2);
$item[$a] = $tmp[0];
$price[$a] = $tmp[1];
if ($item[$a])
{
echo "<input type=checkbox name=itemcheck[$a] value='item'> $item[$a] R
".number_format($price[$a],2)."<br>";
$a++;
}
}
}
echo "<br><input type=submit name=submit value=Submit>
<input type=hidden name=action value=checkout>
</form>";
$a++;
}
if ($action == "checkout")
{
echo "<form method=post>
You have selected the following<br><br>";
for ($b = 1; $b < $a; $b++)
{
if ($itemcheck[$b])
{
$totalprice += $price[$b];
echo "$item[$b] at a cost of R ".number_format($price[$b],2)."<br>";
}
}
echo "<br>Total cost : R ".number_format($totalprice,2)."<br><br>
<a href=http://devin/custom.php?mode=shop&action=selectitems>
Back</a><br>
<a href=http://devin/custom.php?mode=shop&action=checklogin>
Back to start</a><br>
</form>";
}
//some boring code
After you checked some checkboxes and clicked "Submit", you get this:
You have selected the following
juice at a cost of R 0.00
cake at a cost of R 0.00
Total cost : R 0.00
What is the cause of this? What am I doing wrong or what am I not doing?
Easter Bunny