01.
<?php
02.
session_start();
03.
if
(
$_SESSION
[
'UserID'
] ==
""
)
04.
{
05.
echo
"กรุณาเข้าสู่ระบบ"
;
06.
exit
();
07.
}
08.
09.
if
(
$_SESSION
[
'Status'
] !=
"ADMIN"
)
10.
{
11.
echo
"หน้านี้สำหรับผู้ดูแลระบบ"
;
12.
exit
();
13.
}
14.
?>
15.
<html>
16.
17.
<head>
18.
<meta http-equiv=
"Content-Language"
content=
"en-us"
>
19.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
>
20.
<?php
21.
$ID_P
=
$_POST
[
"IDproduct"
];
22.
$N_P
=
$_POST
[
"nameproduct"
];
23.
$D_O
=
$_POST
[
"Dorder"
];
24.
$T_P
=
$_POST
[
"typeProduct"
];
25.
$P_P
=
$_POST
[
"T_Price"
];
26.
$R_P
=
$_POST
[
"recom"
];
27.
include
(
"config.php"
);
28.
?>
29.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
/>
30.
<?
31.
mysql_query(
"SET NAMES UTF8"
);
32.
if
(isset(
$_POST
[
'btn-upload'
]))
33.
{
34.
$file_name
=
$HTTP_POST_FILES
[
'file'
][
'name'
];
35.
$extension
=
strrchr
(
$file_name
,
'.'
);
36.
$random_digit
=rand(0000000000,9999999999);
37.
$new_file_name
=
$random_digit
.
$extension
;
38.
$path
=
"improduct/"
.
$new_file_name
;
39.
if
(
$filUpload
!=none)
40.
if
(
copy
(
$HTTP_POST_FILES
[
'file'
][
'tmp_name'
],
$path
))
41.
{
42.
$strSQL
=
"INSERT INTO ware VALUES ('','$ID_P', '$N_P', '$D_O', '$T_P', '$P_P', '$new_file_name', '$R_P' )"
;
43.
mysql_query(
$strSQL
);
44.
?>
45.
<script>
46.
alert(
'successfully uploaded'
);
47.
window.location.href=
'indexadmin.php?success'
;
48.
</script>
49.
<?php
50.
}
51.
else
52.
{
53.
?>
54.
<script>
55.
alert(
'error while uploading file'
);
56.
window.location.href=
'indexadmin.php?fail'
;
57.
</script>
58.
<?php
59.
}
60.
}
61.
?>