01.
<?php
02.
include
(
"../../../include/connect.php"
);
03.
$strSQL
=
"SELECT * FROM news_pr WHERE news_name = '"
.trim(
$_POST
[
"news_name"
]).
"' "
;
04.
$objQuery
= mysql_query(
$strSQL
);
05.
$objResult
= mysql_fetch_array(
$objQuery
);
06.
if
(
$objResult
)
07.
{
08.
echo
"<table width=
'346'
height=
'35'
border=
'0'
cellpadding=
'0'
cellspacing=
'0'
>
09.
<tr>
10.
<td background=
'../../images/dug.png'
> <span
class
=
'style18'
> บันทึก ชื่อกิจกรรม ซ้ำกันไม่ได้ กรุณาตรวจสอบ !</span>
11.
</td>
12.
</tr>
13.
</table>";
14.
echo
"<meta http-equiv=refresh content=3;URL=news_pr_add.php>"
;
15.
}
16.
else
17.
{
18.
19.
20.
$file
=
strtolower
(
$_FILES
[
"fileupload"
][
"name"
]);
21.
$sizefile
=
$_FILES
[
"fileupload"
][
"size"
];
22.
$type
=
strrchr
(
$file
,
"."
);
23.
if
(
$sizefile
>204800)
24.
{
25.
?>
26.
27.
<script>
28.
window.parent.over_size(
"<?php echo $sizefile/1024?>"
);
29.
</script>
30.
<?php
31.
}
32.
elseif
((
$type
==
".jpg"
)||(
$type
==
".jpeg"
)||(
$type
==
".gif"
)||(
$type
==
".png"
)||(
$type
==
".doc"
)||(
$type
==
".docx"
)||(
$type
==
".pdf"
)||(
$type
==
".tif"
)||(
$type
==
".tiff"
))
33.
{
34.
$tempfile
=
date
(
"Y-m-d"
).
"-"
.
$file
;
35.
if
(
copy
(
$_FILES
[
"fileupload"
][
"tmp_name"
],
"myphoto/"
.
$_FILES
[
"fileupload"
][
"name"
]))
36.
{
37.
38.
$news_name
=
$_POST
[
'news_name'
];
39.
$content
=
$_POST
[
'content'
];
40.
$date_in
=
$_POST
[
'news_day'
];
41.
42.
$date_in
= thaidate(
'j F Y '
);
43.
$strSQL
=
"INSERT INTO news_pr(news_name,content,news_day,image_name) "
44.
.
"VALUES('$news_name','$content','$date_in','"
.
$_FILES
[
"fileupload"
][
"name"
].
"') "
;
45.
46.
$objQuery
= mysql_query(
$strSQL
);
47.
if
(
$objQuery
)
48.
{
49.
echo
"<table width=
'346'
height=
'35'
border=
'0'
cellpadding=
'0'
cellspacing=
'0'
>
50.
<tr>
51.
<td background=
'../../images/end.png'
> <span
class
=
'style17'
> บันทึกข้อมูลเรียบร้อย</span>
52.
</td>
53.
</tr>
54.
</table>";
55.
56.
57.
}
58.
}
59.
60.
?>
61.
<script>
62.
window.parent.uploadok(
"<?php echo $tempfile?>"
);
63.
</script>
64.
<?php
65.
}
66.
else
67.
{
68.
?>
69.
<script>
70.
window.parent.wrong_type(
"<?php echo $_FILES["
fileupload
"]["
name
"]?>"
);
71.
</script>
72.
<?php
73.
}
74.
}
75.
$strSQL
= mysql_close(
$objConnect
);
76.
?>