001.
<!-- sweet alert js & css -->
005.
006.
<?php
007.
008.
include
(
'db_connect.php'
);
009.
session_start();
010.
011.
012.
date_default_timezone_set(
'asia/bangkok'
);
013.
$date1
=
date
(
'Y-m-d H:i:s'
);
014.
015.
$idcard
=
$_POST
[
'idcard'
];
016.
$_SESSION
[
'idcard'
] =
$idcard
;
017.
018.
$username
=
$_POST
[
'name'
];
019.
$_SESSION
[
'username'
] =
$username
;
020.
021.
$section
=
$_POST
[
'section'
];
022.
$_SESSION
[
'section'
] =
$section
;
023.
024.
$status
=
$_POST
[
'select'
];
025.
$_SESSION
[
'y'
] =
$status
;
026.
027.
$serail
=
$_POST
[
'serail'
];
028.
$_SESSION
[
'sr'
] =
$serail
;
029.
030.
$comment
=
$_POST
[
'txtcomment'
];
031.
$_SESSION
[
'cm'
]=
$comment
;
032.
033.
$statuscheck
=
$_POST
[
'status1'
];
034.
$_SESSION
[
'ch'
]=
$statuscheck
;
035.
036.
037.
038.
$fileupload
=
$_FILES
[
'fileupload'
];
039.
040.
041.
date_default_timezone_set(
'Asia/Bangkok'
);
042.
$date
=
date
(
'Ymd'
);
043.
044.
$numrand
= (mt_rand());
045.
046.
047.
$upload
=
$_FILES
[
'fileupload'
];
048.
if
(
$upload
<>
''
) {
049.
050.
$path
=
"./giveback/"
;
051.
052.
$type
=
strrchr
(
$_FILES
[
'fileupload'
][
'name'
],
"."
);
053.
054.
055.
$newname
=
$date
.
$numrand
.
$type
;
056.
$path_copy
=
$path
.
$newname
;
057.
$path_link
=
"fileupload/"
.
$newname
;
058.
059.
060.
move_uploaded_file(
$_FILES
[
'fileupload'
][
'tmp_name'
],
$path_copy
);
061.
}
062.
063.
064.
$sql
= "INSERT INTO tb_return (time,idcard,username,section,status,serial,comment,status1,fileupload)
065.
VALUES (
'$date1'
,
'$idcard'
,
'$username'
,
'$section'
,
'$status'
,
'$serail'
,
'$comment'
,
'$statuscheck'
,
'$newname'
)";
066.
$objQuery
= mysqli_query(
$con
,
$sql
);
067.
$objResult
= mysqli_fetch_array(
$objQuery
,MYSQLI_ASSOC);
068.
if
(
$objResult
){
069.
070.
071.
echo
'<script>
072.
setTimeout(
function
() {
073.
swal({
074.
title:
" !! บันทึกข้อมูลการคืนสำเร็จ !!"
,
075.
text:
"Message!"
,
076.
type:
"success"
077.
},
function
() {
078.
window.location =
"login.php"
;
079.
});
080.
}, 1000);
081.
</script>';
082.
}
083.
else
{
084.
085.
086.
echo
'<script>
087.
setTimeout(
function
() {
088.
swal({
089.
title:
"!! พบข้อผิดพลาด !!"
,
090.
text:
"Message"
,
091.
type:
"success"
092.
},
function
() {
093.
window.location =
"return.php"
;
094.
});
095.
}, 1000);
096.
</script>';
097.
098.
099.
session_destroy();
100.
mysqli_close(
$con
);
101.
102.
}
103.
?>