I have an assignment where i have three html pages for user input and a php confirmation page which needs to display what the user has entered on the previous three pages. Displaying this information in the php page is what i'm having problems with. The page needs to display the quantity, size and colour of widgets the user wants to buy. I have used hidden fields for all three variables and size and colour are displayed fine but i cant get the quantity to be displayed. I think i need to use sessions to solve this but as i am new to php i'm not sure how they work.
Here's my code:
Page 1
CODE
<html>
<head>
<title>Shopping Page</title>
</head>
<body>
<form action = "size.php" method = "post">
Select the quantity of widgets you require
<select name = "selqty">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<br/><br/>
<input type = "submit" value = "Buy"/>
</form>
</body>
</html>
Page 2
CODE
<html>
<head>
<title>Select Size page</title>
</head>
<body>
<form action = "selectcolour.php" method = "post">
Select the size of widgets you require
<select name = "selsize">
<option>Small</option>
<option>Medium</option>
<option>Large</option>
<option>Extra Large</option>
</select>
<br/><br/>
<input type = "hidden" name = "hdqty" value = "<?php echo $_POST[selqty]?>"/>
<input type = "submit" value = "Buy"/>
</form>
</body>
</html>
Page 3
CODE
<html>
<head>
<title>Select colour page</title>
</head>
<body>
<form action = "confirmation1.php" method = "post">
Select the colour for the <?php echo $_POST[selqty]?> widgets you are ordering
<select name = "selcolour">
<option>White</option>
<option>Red</option>
<option>Yellow</option>
<option>Green</option>
<option>Blue</option>
</select>
<br/><br/>
<input type = "hidden" name = "hdqty" value = "<?php echo $_POST[selqty]?>"/>
<input type = "hidden" name = "hdsize" value = "<?php echo $_POST[selsize]?>"/>
<input type = "submit" value = "Buy"/>
</form>
</body>
</html>
PHP file:
CODE
<?
session_start();
$_SESSION['quantity'] = "selqty";
echo $_SESSION['quantity'];
echo "<h2>Your size selection is $_POST[hdsize]</h2><br/>";
echo "<h2>The colour selected is $_POST[selcolour]</h2>";
?>
As you can see i've put in a session variable for quantity but all that is displayed is the word 'selqty', rather than the quantity option entered by the user. I don't know how to make it select the correct option from the first page. Can anyone help please?