I've been having an issue passing hidden values over the past few days and am just displaying an update if anyone might be able to help me find a solution. I realise it's probably simple but I can't seem to get it working so any help would be great.

Can someone have a look at how I'm passing the values to see if there's something I should be doing to get them outputting on the process.php page.

list.php

Code:
echo '<form action ="cart.php" method="post">';
echo'<p><table border = "1" cellspacing="1">';
echo'<tr><td>Title</td><td>CD</td><td>Quantity</td></tr>';
while($row = mysql_fetch_array($result)){
	echo '<tr>';
	echo '<td>'. $row['title'] .'</td>';
	echo '<td>'. $row['cd'] .'</td>';
	echo '<td><input name ="'.$row['productid'].'" type="text" /></td>';
	echo '</tr>';
}
echo'</table></p>';
echo'<input name="submit" type="submit" />';
echo'</form>';
cart.php

Code:
<?php
        foreach($_POST as $key => $value){
        	echo $key.'';
        	echo 'The quantity is:'.$value;
        	echo '<br/>';
        }
        ?>

        <form action="process.php" method="post">
        <table>
	<td><input type="hidden" name="productid" id="productid" value="<?php echo $key; ?>" /></td>
<td><input type="hidden" name="quantity" id="quantity" value="<?php echo $value; ?>" /></td>
        <tr>
            <td>First name:</td>
            <td><input name="firstname" type="text" value="<?php if(isset($_POST) && isset($_POST['firstname'])){
        		echo $row['firstname'];
        	}
        	?>"/></td>
            <td></td>
          </tr>
          <tr>
            <td>Last name:</td>
            <td><input name="lastname" type="text" value="<?php if(isset($_POST)&& isset($_POST['lastname'])){
        		echo $_POST['lastname'];
        	}
        	?>" /></td>
            <td></td>
          </tr>
        <tr>
            <td></td>
            <td><input name="submit" type="submit" value="submit" /></td>
            <td>&nbsp;</td>
          </tr>
        </table>
        </form>
process.php

I've inserted the following to retrieve the posted variables sent in the hidden fields of the form on cart.php page:

Code:
echo $_POST['productid'];
echo $_POST['quantity'];