I'm trying to make a page that takes a form submission and adds the contents as a new value in the $_SESSION() array, what seems to be happening though is the value is being overridden.
The form has 3 text inputs named a, b and c and refreshes the page on submission. What tells me it's being replaced is $_SESSION[0] will display 1 2 and 3 as defined below, then the next row defined by $_POST will be the same but with the array values replaced by the last submitted values rather than adding the last submitted as another row.
<form action="test2.php" method="post">
<input type="text" name="a">
<input type="text" name="b">
<input type="text" name="c">
<input type="submit" value="Submit">
</form>
<?php
if (isset($_POST['a']))
{
$a = $_POST['a'];
$b = $_POST['b'];
$c = $_POST['c'];
$order = array('a' => $a, 'b' => $b, 'c' => $c);
$_SESSION[0] = array('a' => 1, 'b' => 2, 'c' => 3);
$_SESSION[] = $order;
$count = count($_SESSION);
for ($i = 0; $i < $count; $i++) {
echo "w: " . $_SESSION[$i]['a'] . "\n";
echo "h: " . $_SESSION[$i]['b'] . "\n";
echo "p: " . $_SESSION[$i]['c'] . "\n";
echo "<br />";
}
}
?>
Would be extremely grateful for any help, Thanks