<?php
# here we're trying to figure out how to make all of this work
# mainly the issue at hand is figuring out the _POST vars...
# it looks like it's an array or something?

# the function that processes POST variables
#include('getpostvars.inc');

# I have no idea how to to $_POST for an array
#$materials = $_POST[$materials];
#$quantity = $_POST[$quantity];
#$materials = $_POST[$materials];
#
# ok, this works...
#$materials["quantity"][1] = $_POST["materials"]["quantity"][1];


#foreach ($_POST as $array) { for ($i=0; $i<5; $i++) {echo $array[i]; }}



# here we send our POST variables off to be processed
#$password			= getpostvars('password', 16);


# let's set up our database connection
#include ('database.inc');


?>

<form action="<?= $PHP_SELF; ?>" method="POST" enctype="text">

<p><big><b>Materials Used</big></b>
<table>
  <tr>
    <th>
      Quantity
    </td>
    <th>
      Description
    </td>
    <th>
      Unit Price
    </td>
    <th>
      Extended
    </td>
  </tr>

  <?php
  # loop places materials into an array
  for ($line=1; $line <= 5; $line++) {
    $materials[$line]["quantity"] = $_POST["materials"][$line]["quantity"];
	$materials[$line]["item_description"] = $_POST["materials"][$line]["item_description"];
	$materials[$line]["unitprice"] = $_POST["materials"][$line]["unitprice"];
    echo "
    <tr>
      <td align=center><input type=\"text\" name=\"materials[$line][quantity]\"
        size=4 value=\"" . $materials[$line]["quantity"] . "\">  </td>
      <td align=left><input type=\"text\" name=\"materials[$line][item_description]\"
        size=60 value=\"" . $materials[$line]["item_description"] . "\">  </td>
      <td align=right><input type=\"text\" name=\"materials[$line][unitprice]\"
        size=7 value=\"" . $materials[$line]["unitprice"] . "\">  </td>
      <td align=right>\$" . number_format($materials[$line]["extended"],2) . "  </td>
    </tr>";
  }
  ?>

</table>



<?php
###############################################################################################
#                                      form submittal                                         #
###############################################################################################
?>
<p><input type=checkbox name="verified" value="true"> All data has been verified.
<p><input type=submit value="Submit"></p>
</form>

<P>
<?php
print_r($_POST);
?>
