ท่านใดเก่ง php รบกวนช่วยผมทีครับ

กระทู้คำถาม
<?php require_once('Connections/dbconnect.php'); ?>
<?php require_once('Connections/dbconnect.php'); ?>
<?
$hour = date("H")-1;
date($format);
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_dbconnect, $dbconnect);
$query_matunit = "SELECT * FROM unitlist";
$matunit = mysql_query($query_matunit, $dbconnect) or die(mysql_error());
$row_matunit = mysql_fetch_assoc($matunit);
$totalRows_matunit = mysql_num_rows($matunit);

mysql_select_db($database_dbconnect, $dbconnect);
$query_form1 = "SELECT * FROM inventory";
$form1 = mysql_query($query_form1, $dbconnect) or die(mysql_error());
$row_form1 = mysql_fetch_assoc($form1);
$totalRows_form1 = mysql_num_rows($form1);

mysql_select_db($database_dbconnect, $dbconnect);
$query_matstore = "SELECT * FROM tb_storematerial ORDER BY ID ASC";
$matstore = mysql_query($query_matstore, $dbconnect) or die(mysql_error());
$row_matstore = mysql_fetch_assoc($matstore);
$totalRows_matstore = mysql_num_rows($matstore);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jquery use json data</title>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script type="text/javascript" src="ajax.js" ></script>
<script src="SpryAssets/SpryValidationSelect.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<style type="text/css">
#form1 p label {
    font-size: 14px;
}
#form1 table {
    font-size: 14px;
}
body {
    background-image: url(image/g2.jpg);
    font-size: 14px;
}
a:link {
    font-size: 16px;
}
a:link {
    font-size: 16px;
}
a:visited {
    font-size: 16px;
}
a:active {
    font-weight: bold;
}
</style>
<link href="SpryAssets/SpryValidationSelect.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>

<body >

<form id="form1" name="form1" method="POST" >  
<table width="600" border="1" align="center" cellspacing="0">
  <tr>
    <td width="81" align="center" bgcolor="#66CCFF">รหัสพนักงาน</td>
    <td width="100" bgcolor="#FFCC99"><?php echo $username ?> </td>
    <td width="82" align="center" bgcolor="#66CCFF">ชื่อ-นามสกุล</td>
    <td width="152" bgcolor="#FFCC99"><?php echo $fname ?> <?php echo $lname ?> </td>
    <td width="56" align="center" bgcolor="#66CCFF">ตำแหน่ง</td>
    <td width="109" bgcolor="#FFCC99"><?php echo $sdept ?> </td>
  </tr>
</table>
<table width="450" border="1" align="center" cellspacing="0">
  <tr>
    <td width="82" align="center" bgcolor="#66CCFF">เบอร์โทรศัพท์</td>
    <td width="134" bgcolor="#FFCC99"><?php echo $smobile ?> </td>
    <td width="42" align="center" bgcolor="#66CCFF">อีเมล์</td>
    <td width="197" bgcolor="#FFCC99"><?php echo $semail ?> </td>
  </tr>
</table>
<br />
<table width="600" border="1" align="center" cellspacing="0">
  <tr bgcolor="#FFCCCC">
    <td colspan="5" align="center" valign="middle"><strong>ค้นหารายการ</strong></td>
  </tr>
  <tr>
    <td align="center" valign="middle" bgcolor="#FFFFCC">รหัสสินค้า</td>
    <td width="300" align="center" valign="middle" bgcolor="#FFFFCC">รายการสินค้า</td>
    <td width="30" align="center" bgcolor="#FFFFCC">หน่วย</td>
    <td width="50" align="center" bgcolor="#FFFFCC">จำนวนที่เบิก</td>
    <td width="50" align="center" bgcolor="#FFFFCC">หมายเหตุ</td>
  </tr>
  <tr bgcolor="#FFCCCC">
    <td align="center" valign="middle" bgcolor="#FFFFCC"><select name="matcode" id="matcode" OnChange="window.location='?item='+this.value;">
      <option value="">ตัวเลือก</option>
      <?
            $strSQL = "SELECT * FROM inventory ORDER BY IntVCode ASC";
            $objQuery = mysql_query($strSQL);
            while($objResult = mysql_fetch_array($objQuery))
            {
                if($_GET["item"] == $objResult["IntVCode"])
                {
                    $sel = "selected";
                }
                else
                {
                    $sel = "";
                }
            ?>
      <option value="<?=$objResult["IntVCode"];?>" <?=$sel;?>>
        <?=$objResult["IntVCode"];?>
        </option>
      <?
            }
            ?>
      </select>
      <?
          if($_GET["item"] != "")
          {
            $strSQL = "SELECT * FROM inventory WHERE IntVCode = '".$_GET["item"]."' ";
            $objQuery = mysql_query($strSQL);
            $objResult2 = mysql_fetch_array($objQuery);
          }

          ?>
      <td align="center" valign="middle" bgcolor="#FFFFCC"><input name="matdetail" type="text" value="<?=$objResult2["IntVName"];?>" size="60" /></td>
    <td align="center" valign="middle" bgcolor="#FFFFCC"><span id="spryselect1">
      <select name="matunit" id="matunit">
        <option value="">ตัวเลือก</option>
        <?php
do {  
?>
        <option value="<?php echo $row_matunit['name']?>"><?php echo $row_matunit['name']?></option>
        <?php
} while ($row_matunit = mysql_fetch_assoc($matunit));
  $rows = mysql_num_rows($matunit);
  if($rows > 0) {
      mysql_data_seek($matunit, 0);
      $row_matunit = mysql_fetch_assoc($matunit);
  }
?>
        </select>
      </span></td>
    <td align="center" valign="middle" bgcolor="#FFFFCC"><span id="sprytextfield1">
      <input type="text" name="mateach" id="mateach" />
      </span></td>
    <td align="center" valign="middle" bgcolor="#FFFFCC"><span id="sprytextfield2">
      <input type="text" name="matnote" id="matnote" />
      </span></td>
  </tr>
  <tr bgcolor="#FFCCCC">
    <td colspan="5" align="center" valign="middle" bgcolor="#FFFFCC"><table width="820" border="0">
      <tr>
        <td> </td>
        <td width="248" align="left"><input type="submit" name="button" id="button" value="เพิ่มลงรายการ" /></td>
        <td width="201" align="center"><table width="200" border="1">
          <tr>
            <td align="center" bgcolor="#66FF99"><?php
echo date("d-m-Y $hour:i:s");
?> </td>
            </tr>
          </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<p> </p>
<p> </p>
</form>

<form id="form2" name="form2" method="post" action="">
 
<table width="900" border="1" align="center" cellspacing="0">
  <tr>
    <td colspan="7" align="center" bgcolor="#FFCCCC"><strong>รายการสินค้าที่เพิ่มเข้ามา</strong></td>
    </tr>
  <tr>
    <td width="30" align="center" bgcolor="#FFFFCC">ลำดับที่</td>
    <td width="60" align="center" bgcolor="#FFFFCC">รหัสสินค้า</td>
    <td width="200" align="center" bgcolor="#FFFFCC">รายการสินค้า </td>
    <td width="20" align="center" bgcolor="#FFFFCC">หน่วย</td>
    <td width="20" align="center" bgcolor="#FFFFCC">จำนวนที่เบิก</td>
    <td width="40" align="center" bgcolor="#FFFFCC">หมายเหตุ</td>
    <td width="48" bgcolor="#FFFFCC"> </td>
  </tr>
  <tr>
  <tr>
    <td align="left" bgcolor="#FFFFCC"> </td>
    <td align="center" bgcolor="#FFFFCC"> </td>
    <td align="center" bgcolor="#FFFFCC"> </td>
    <td align="center" bgcolor="#FFFFCC"> </td>
    <td align="center" bgcolor="#FFFFCC"> </td>
    <td align="center" bgcolor="#FFFFCC"> </td>
    <td align="center" bgcolor="#FFFFCC"><a href="delete.php?ID=<?php echo $row_matstore['ID']; ?>">ลบ</a></td>
  </tr>
<tr>
    <td colspan="7" align="center" bgcolor="#FFFFCC"><input type="submit" name="button2" id="button2" value="Submit" /></td>
    </tr>
</table>
<p> </p>
</form>
<p> </P>
<p> </P>
<script type="text/javascript">
var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1");
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
</script>
</body>
</html>
<?php
mysql_free_result($matunit);

mysql_free_result($form1);

mysql_free_result($matstore);
?>

ความต้องการของผมคือ ส่งข้อมูลจาก Form1 ไปสู่ฐานข้อมูลแต่ให้ Form1 ส่งข้อมูลเพื่อดูรายการที่จะส่งทั้งหมดไป Form2 ก่อนแล้วจึงส่งข้อมูลเข้าฐานข้อมูลทีหลัง ผมต้องเขียนโค้ดประมาณไหนครับ
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่