001.
<?php
002.
$Show1
=
$_POST
[
"DO_name"
];
003.
$Show2
=
$_POST
[
"Date"
];
004.
$Show3
=
$_POST
[
"customer_id"
];
005.
$Show4
=
$_POST
[
"Product_id"
];
006.
$Show5
=
$_POST
[
"Container"
];
007.
$Show6
=
$_POST
[
"PlateofTruck"
];
008.
$user_id
=
$_REQUEST
[
"user_id"
];
009.
?>
010.
<form id=
"contact"
name=
"frmMain"
method=
"post"
action=
"insert1.php"
>
011.
<table width=
"40%"
border=
"1"
>
012.
<tr>
013.
<th width=
"48%"
height=
"27"
>กรอกหมายเลข DO.</th>
014.
<td>
015.
<?php
016.
017.
$sqlcheck
= "SELECT DO_name FROM
do
018.
WHERE DO_Name=
'".$Show1."'
;
" or die("
Error:" . mysqli_error());
019.
$result
= mysqli_query(
$conn
,
$sqlcheck
);
020.
if
(
$result
->num_rows > 0) {
021.
echo
'<script type="text/javascript">alert("เลข Do นี้ซ้ำ");'
;
022.
023.
echo
"</script>"
;
024.
025.
}
026.
else
{
027.
$do
=
$_POST
[
"DO_name"
];
028.
029.
030.
031.
?>
032.
<input name=
"DO_name"
type=
"text"
id=
"DO_name"
maxlength =
"10"
value=
"<?php echo $do; ?>"
/>
033.
<!--<label><?php
echo
$text
;?></label>-->
034.
</td>
035.
</tr>
036.
037.
<tr>
038.
<th>วัน/เดือน/ปี ที่ขนส่ง</th>
039.
<td><input name=
"Date"
type=
"date"
id=
"Date"
require
style=
"width:75%;"
placeholder=
"YYYY-MM-DD"
></td>
040.
</tr>
041.
<tr>
042.
<th>ลูกค้า</th>
043.
<td>
044.
<input list=
"customer_id"
name=
"customer_id"
value=
"<?php echo $customer; ?>"
>
045.
<datalist id=
"customer_id"
>
046.
<?php
047.
include
(
"connect2.php"
);
048.
$result
=
$conn
->query(
"select customer_id, customer_name from customer"
);
049.
while
(
$row
=
$result
->fetch_assoc()) {
050.
unset(
$id
,
$name
);
051.
$id
=
$row
[
'customer_id'
];
052.
$name
=
$row
[
'customer_name'
];
053.
echo
'<option value="'
.
$id
.
'" value="'
.
$id
.
'">'
.
$name
.
'</option>'
;
054.
}
055.
?>
056.
</datalist>
057.
</td>
058.
</tr>
059.
060.
<tr>
061.
<th>สินค้า</th>
062.
<td>
063.
<input list=
"Product_id"
name=
"Product_id"
value=
"<?php echo $product; ?>"
>
064.
<datalist id=
"Product_id"
>
065.
<?php
066.
include
(
"connect2.php"
);
067.
$result
=
$conn
->query(
"select Product_id, Product_name from product"
);
068.
while
(
$row
=
$result
->fetch_assoc()) {
069.
unset(
$id
,
$name
);
070.
$id
=
$row
[
'Product_id'
];
071.
$name
=
$row
[
'Product_name'
];
072.
echo
'<option value="'
.
$id
.
'" type="hidden">'
.
$name
.
'</option>'
;
073.
}
074.
?>
075.
</datalist>
076.
</td>
077.
</tr>
078.
</table>
079.
<br>
080.
<table width=
"40%"
border=
"1"
>
081.
<tr>
082.
<th width=
"48%"
height=
"27"
>ทะเบียนรถ</th>
083.
<td ><input name=
"PlateofTruck"
type=
"text"
id=
"PlateofTruck"
style=
"width:75%;"
></td>
084.
</tr>
085.
<tr>
086.
<th width=
"48%"
height=
"27"
>หมายเลขตู้คอนเทนเนอร์</th>
087.
<td ><input name=
"Container"
type=
"text"
id=
"Container"
style=
"width:75%;"
></td>
088.
</tr>
089.
<tr>
090.
<td></td>
091.
<td> <input type =
"hidden"
name =
"user_id"
value=
"<?php echo $user_id; ?>"
>
092.
<input type=
"submit"
name=
"Submit"
value=
"บันทึก"
id=
"add"
></td>
093.
</tr>
094.
</table>
095.
<?php
096.
097.
if
(
$Show1
&&
$Show2
!=null){
098.
099.
mysqli_set_charset(
$conn
,
"utf8"
);
100.
ob_start();
101.
102.
$sql
= "INSERT INTO
do
(DO_name,
Date
,customer_id,Product_id,Container,PlateofTruck,user)
103.
VALUES (
'".$Show1."'
,
'".$Show2."'
,
104.
'".$Show3."'
,
'".$Show4."'
,
105.
'".$Show5."'
,
'".$Show6."'
,
'".$user_id."'
)";
106.
107.
if
(
$conn
->query(
$sql
) === TRUE){
108.
echo
'<script type="text/javascript">alert ("บันทึกสำเร็จ");'
;
109.
echo
"</script>"
;
110.
}
111.
else
{
112.
echo
"บันทึกไม่สำเร็จ"
;
113.
}
114.
}
115.
116.
}
117.
118.
119.
?>
120.
</form>