So I am trying to request variables on an order confirmation page that were populated from a text file on the form page. The problem I'm having is getting them to show up on the confirmation page.
Here is the web pages for reference.
orderGroceries.phpHere is the text file where the table data is populated.
groceryInventory.txtCODE
Cabbage .39 lb
Broccoli 1.89 lb
Kiwi 0.25 ea
Tomacco 15.86 lb
Free-Range Eggs 3.95 doz
This is the order form.
orderGroceries.phpCODE
<?php
// Read in the entire file.
$groceryInventory= file("inventory/groceryInventory.txt");
// Count the number of elements
$amount_of_inventory = count($groceryInventory);
if ($amount_of_inventory == 0) {
echo '<p><strong>You have no inventory! Add some to your stock.</strong></p>';
}
echo '<table border="0">
<tr align="left">
<th>Item</th>
<th>Price</th>
<th>Unit</th>
<th>Quantity</th>
<tr>';
for ($i=0; $i<$amount_of_inventory; $i++) {
// Alternates Colours
$colour1 = '#CCCCCC';
$colour2 = "#FFFFFF";
$lineCount = "0";
$lineColour = ($i % 2 == 0) ? $colour1 : $colour2;
// Split up each line
$line = explode( "\t", $groceryInventory[$i] );
$line[1] = floatval( $line[1] );
// $line[2] =intval( $line[2] );
// $line[3] =intval( $line[3] );
// Output the elements of the text file
echo "<tr>
<td bgcolor='$lineColour'>$line[0]</td>
<td bgcolor='$lineColour'align='right'> $line[1]</td>
<td bgcolor='$lineColour' align='right'>$line[2]</td>";
// Convert string to lower case
$line[0] = strtolower($line[0]);
// Remove spaces from string
$line[0] = str_replace (" ", "", $line[0]);
//This creates a text input box using the name of the item so it can be passed to the confirmation page
echo "<td bgcolor='$lineColour' align='right'><input type='text' name='$line[0]' maxlength='2' size='4' /></td> [color=#FF0000]<== this uses the item name from the text file to name the text input boxes[/color]
</tr>";
}
echo '</table>';
?>
This is the file where I am having problems. I want to request the variable names from the previous page without listing them all off ($tomacco = $_POST['tomacco']' etc....). This is an exact copy o the order form, except the input box is replaced by the number of items ordered.
Area in question is at the bottom.
fillOrder.phpCODE
<?php
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$address = $_POST['address'];
$city = $_POST['city'];
echo '<tr>
<td>Full Name: <b>'.$firstName.' '.$lastName.'</b></td>
</tr>
<tr>
<td>Address: <b>'.$address.'</b></td>
</tr>
<tr>
<td>City: <b>'.$city.'</b></td>
</tr>
<tr>
<td>';
// Read in the entire file.
$groceryInventory= file("inventory/groceryInventory.txt");
// Count the number of elements
$amount_of_inventory = count($groceryInventory);
if ($amount_of_inventory == 0) {
echo '<p><strong>You have no inventory! Add some to your stock.</strong></p>';
}
echo '<table border="0">
<tr align="left">
<th>Item</th>
<th>Price</th>
<th>Unit</th>
<th>Quantity</th>
<tr>';
for ($i=0; $i<$amount_of_inventory; $i++) {
// Alternates Colours
$colour1 = '#CCCCCC';
$colour2 = "#FFFFFF";
$lineCount = "0";
$lineColour = ($i % 2 == 0) ? $colour1 : $colour2;
// Split up each line
$line = explode( "\t", $groceryInventory[$i] );
$line[1] = floatval( $line[1] );
// $line[2] =intval( $line[2] );
// $line[3] =intval( $line[3] );
// Output the elements of the text file
echo "<tr>
<td bgcolor='$lineColour'>$line[0]</td>
<td bgcolor='$lineColour'align='right'> $line[1]</td>
<td bgcolor='$lineColour' align='right'>$line[2]</td>";
// Convert string to lower case
$line[0] = strtolower($line[0]);
// Remove spaces from string
$line[0] = str_replace (" ", "", $line[0]);
//This creates a text input box using the name of the item so it can be passed to the confirmation page
echo "<td bgcolor='$lineColour' align='right'>
This is where I need the number of items ordered to be displayed
</td>
</td>
</tr>";
}
echo '</table>';
?>
I have tried a few things, but cant seem to figure out how to accomplish this task. Any input on how to accomplish this would be greatly appreciated!
This post has been edited by vicious: 27 Jan, 2008 - 06:28 PM