01.
<?
02.
session_start();
03.
include
(
"../inc/libdb.php"
);
04.
include
(
"../admin/checklogin_admin.php"
);
05.
ConnectDB();
06.
07.
08.
if
(
$save
) {
09.
10.
$SQL
=
"SELECT * FROM product WHERE pro_serial ='$pro_serial' LIMIT 1;"
;
11.
$RS
= mysql_query(
$SQL
);
12.
if
(mysql_num_rows(
$RS
)==1){
13.
echo
"<script language=\"javascript\">alert('ขอโทษค่ะ ชื่อรหัสสินค้าซ้ำ');history.back();</script>"
;
14.
CloseDB();
15.
exit
();
16.
}
17.
18.
19.
$SQL
="INSERT INTO product (pro_serial,pro_type_id,pro_type2_id,pro_type3_id,pro_type4_id,pro_type5_id,pro_type6_id,pro_name,pro_detail,pro_price,pro_check_id,pro_buy_id,image)
20.
values (
'$pro_serial'
,
'$pro_type'
,
'$pro_type2'
,
'$pro_type3'
,
'$pro_type4'
,
'$pro_type5'
,
'$pro_type6'
,
'$pro_name'
,
21.
'$pro_detail'
,
'$pro_price'
,
'$pro_check'
,
'$pro_buy '
,
$pic_name
')";
22.
mysql_query(
$SQL
);
23.
24.
25.
if
(
$image
){
26.
$code
= mysql_insert_id();
27.
$file
=
explode
(
"."
,
$image_name
);
28.
$file
= sprintf(
"%05d"
,
$code
).
".$file[1]"
;
29.
mysql_query(
"UPDATE product SET image='$file' where pro_id =$code LIMIT 1;"
)
or
die
(mysql_error());
30.
copy
(
$image
,
"../img/product/$file"
);
31.
32.
33.
echo
"<script language=\"javascript\">alert('ระบบได้ทำการบันทึกข้อมูลเรียบร้อยแล้วค่ะ');</script>"
;
34.
echo
"<script language=\"JavaScript\">parent.location.href='pro_add.php';</script>"
;
35.
36.
37.
}
38.
39.
40.
41.
CloseDB();
42.
43.
exit
();
44.
45.
}
46.
?>