I've been working around trying to fix it and I used multiple $_SESSION["variable"] but it only stored one session variable. Then I used session_register("variable"); and it too, only stored one variable, but a different variable. Here's the code if anyone wants to help out. take not that I've removed code that has absolutely nothing to do.
data.php
CODE
<?php
session_start();
srand((double)microtime() * 1000000);
$minerals_1 = rand(0, 2500);
$_SESSION['minerals_1'] = $minerals_1;
?>
index.php
CODE
<?php
session_start();
echo <<<HTML
<form action="form.php" method="POST">
Enter the amount of minerals you wish to bet: <input type="text" name="minbet" /><br />
<input type="submit" />
</form>
HTML;
require_once ("data.php");
echo "You currently have {$minerals_1} minerals <br />";
?>
form.php
CODE
<?php
session_start();
error_reporting(E_ALL & ~E_NOTICE);
$minerals_1 = $_SESSION['minerals_1'];
if ($minerals_1 < $_POST["minbet"])
{
echo <<<HTML
<meta http-equiv="refresh" content="1; URL=error.php">
HTML;
}
elseif ($minerals_1 >= $_POST["minbet"])
{
$minerals_2 = $minerals_1 - $_POST["minbet"];
$minbet = $minerals_1 - $minerals_2;
echo "You have selected {$minbet} minerals to bet with.<br /> You currently have {$minerals_2} after placing your bet.<br />";
include ("dice_func.php");
}
?>
dice_func.php
CODE
<?php
session_start();
$minerals_1 = $_SESSION['minerals_1'];
$minerals_2 = $_SESSION['minerals_2'];
$minbet = $_SESSION['minbet'];
echo "{$minerals_1} = minerals_1<br />";
echo "{$minerals_2} = minerals_2<br />";
echo "{$minbet} = minbet<br />";
srand((double)microtime() * 1000000);
$diceroll_1 = rand(1, 6);
switch ($diceroll_1)
{
case 1:
echo "You've rolled a 1, you've lost {$minbet} minerals";
break;
case 2:
echo "You've rolled a 2, you've lost {$minbet} minerals";
break;
}
?>