สร้างฟอร์มเดียวแต่บันทึกคนละตารางในฐานข้อมูลง่ายมากๆ เลยครับ

ตัวอย่างนี้จะมี 2 ไฟล์
checkin_form.php //เก็บฟอร์มกรอกข้อมูล
checkin_process.php //ประมวลผลข้อมูล

------------------------------------------------------------------------------------------------------

ไฟล์ checkin_form.php
  <form id="checkin_form" name="checkin_form" method="post" action="checkin_process.php">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td class="style5"><div align="center" class="style6">ข้อมูลการเข้าพัก / CHECK IN</div></td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                </tr>
                        </table></td>
          </tr>
          <tr>
            <td width="22%">&nbsp;</td>
            <td width="18%"><span class="style19">เลขห้อง :</span></td>
            <td width="60%"><label>
            <input name="Room_Id" type="text" id="Room_Id" size="6" maxlength="6" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">ประเภทห้อง :</span></td>
            <td><label>
              <select name="Room_Type" id="Room_Type">
                <option value="A">แอร์</option>
                <option value="F">พัดลม</option>
              </select>
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">ค่าห้อง :</span></td>
            <td><label>
              <input name="Room_Price" type="text" id="Room_Price"
                 size="6" maxlength="6"  />
            <span class="style23">บาทต่อเดือน              </span></label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">ค่าบริการ :</span></td>
            <td><label>
              <input name="Room_Service" type="text" id="Room_Service" size="6" maxlength="6" />
              <span class="style23">บาทต่อเดือน</span></label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">เลขบัตรประชาชน :</span></td>
            <td><label>
              <input name="Cus_Id" type="text" id="Cus_Id" size="13" maxlength="13" />
              <span class="style23">13 หลัก</span></label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">ชื่อ - สกุล :</span></td>
            <td><label>
              <input name="Cus_Name" type="text" id="Cus_Name" size="50" maxlength="50" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">โทรศัพท์บ้าน :</span></td>
            <td><label>
              <input name="Cus_Phone" type="text" id="Cus_Phone" size="10" maxlength="10" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">มือถือ :</span></td>
            <td><label>
              <input name="Cus_Mobile" type="text" id="Cus_Mobile" size="10" maxlength="10" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">อีเมล์ :</span></td>
            <td><label>
              <input name="Cus_Email" type="text" id="Cus_Email" size="50" maxlength="50" />
              <span class="style23">[email protected]</span>
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">บ้านเลขที่ :</span></td>
            <td><label>
              <input name="Cus_No" type="text" id="Cus_No" size="6" maxlength="6" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">หมู่ที่ :</span></td>
            <td><label>
              <input name="Cus_village" type="text" id="Cus_village" size="2" maxlength="2" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">ตำบล :</span></td>
            <td><label>
              <input name="Cus_District" type="text" id="Cus_District" size="40" maxlength="40" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">อำเภอ :</span></td>
            <td><label>
              <input name="Cus_Amphur" type="text" id="Cus_Amphur" size="40" maxlength="40" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">จังหวัด :</span></td>
            <td><label>
              <input name="Cus_Province" type="text" id="Cus_Province" size="40" maxlength="40" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">เพศ :</span></td>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="15%"><label>
                  <input type="radio" name="Cus_Sex" id="radio" value="M" />
                  <span class="style24">เพศชาย                  </span></label></td>
                <td width="85%"><label>
                  <input type="radio" name="Cus_Sex" id="radio2" value="F" />
                  <span class="style24">เพศหญิง</span></label></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">วันเกิด :</span></td>
            <td><label>
              <input name="Cus_Birthday" type="text" id="Cus_Birthday" size="10" maxlength="10" />
              <span class="style23">19/02/2529</span></label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">อาชีพ :</span></td>
            <td><label>
              <input name="Cus_Occupation" type="text" id="Cus_Occupation" size="20" maxlength="20" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">คณะ :</span></td>
            <td><label>
              <input name="Cus_Faculty" type="text" id="Cus_Faculty" size="20" maxlength="20" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><span class="style19">สถานะภาพ :</span></td>
            <td><label>
              <select name="Cus_Status" id="Cus_Status">
                <option value="0">โสด</option>
                <option value="1">แต่งงาน</option>
                <option value="2">หย่า</option>
              </select>
            </label></td>
          </tr>
          <tr>
            <td colspan="3"><p>&nbsp;</p>
            <p>&nbsp;</p></td>
          </tr>
          <tr>
            <td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="30%">&nbsp;</td>
                <td width="8%">&nbsp;</td>
                <td width="6%"><label>
                  <input type="submit" name="submit" id="submit" value="ยีนยัน" />
                </label></td>
                <td width="7%"><label>
                  <input name="cancel" type="reset" id="cancel" value="ยกเลิก" />
                </label></td>
                <td width="10%"><label>
                  <input type="submit" name="search" id="search" value="ค้นหา" />
                </label></td>
                <td width="9%">&nbsp;</td>
                <td width="30%">&nbsp;</td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td colspan="3">&nbsp;</td>
          </tr>
        </table>
      </form>

-----------------------------------------------------------------------------------------------

ไฟล์ checkin_process.php
<?php
include("conn_db.php");
$room_id=$_POST[Room_Id];
$room_type=$_POST[Room_Type];
$room_price=$_POST[Room_Price];
$room_service=$_POST[Room_Service];
$cus_id=$_POST[Cus_Id];
$cus_name=$_POST[Cus_Name];
$cus_phone=$_POST[Cus_Phone];
$cus_mobile=$_POST[Cus_Mobile];
$cus_email=$_POST[Cus_Email];
$cus_no=$_POST[Cus_No];
$cus_village=$_POST[Cus_Village];
$cus_district=$_POST[Cus_District];
$cus_amphur=$_POST[Cus_Amphur];
$cus_province=$_POST[Cus_Province];
$cus_sex=$_POST[Cus_Sex];
$cus_birthday=$_POST[Cus_Birthday];
$cus_occupation=$_POST[Cus_Occupation];
$cus_faculty=$_POST[Cus_Faculty];
$cus_status=$_POST[Cus_Status];

 


if($cus_id==null || $cus_name==null){

 echo"<a href=\"checkin.php\"> คุณกรอกข้อมูลไม่สมบูรณ์</a>\n";
 
 }else{
 $query="INSERT INTO rent_room VALUES('','$room_id','$room_type','$room_price','$room_service','')";
 $query2="INSERT INTO customer  VALUES

('$cus_id','$cus_name','$cus_phone','$cus_mobile','$cus_emial','$cus_no','$cus_village','$cus_district','$cus_amphur','$cus_province','$cus_sex','$cus_birthday','$cus_occupation','$cus_faculty','$cus_status')";
 $result=@mysql_query($query) or die("ไม่สามารถเพิ่มได้".mysql_error());
 $result2=@mysql_query($query2) or die("ไม่สามารถเพิ่มได้2".mysql_error()); 
 
 echo "<h2><p align=\"center\">เพิ่มเรียบร้อยแล้ว</p></h2>"; 
  
 echo  "<center><a href =\"checkin.php\">กลับหน้าหลัก</a>"; 
  
 }

?>