The foreach statement in the cart.php prints out the productid value and the quantity. What I want to do now is the to post these values from cart.php page to process.php, as I want to be able to include the details when writing an insert statement for the order table. This would also contain the customer id from the customer table along with the productid and quantity.

Do I post the variables $key and $value in this instance to pass them to the process.php page as requested in the form action request. I presume they'd be passed using hidden input fields but I'm unsure on this.

Any help would be great.


echo '<form action ="cart.php" method="post">';
echo'<p><table border = "1" cellspacing="1">';
while($row = mysql_fetch_array($result)){
	//print out all the details from the database table row in cells in a html table row
	echo '<tr>';
	echo '<td>'. $row['title'] .'</td>';
	echo '<td>'. $row['cd'] .'</td>';
	echo '<td><input name ="'.$row['productid'].'" type="text" /></td>';
	echo '</tr>';

echo'<input name="submit" type="submit" />';

foreach($_POST as $key => $value){
	if ($value > 0){
	echo $key.'';
	echo 'The quantity is:'.$value;
	echo '<br/>';

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