001.
<? session_start ();
002.
003.
004.
005.
006.
007.
008.
?>
011.
<head>
012.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=windows-874"
/>
013.
<title>:: ฟอร์มสินค้า ::</title>
014.
<style type=
"text/css"
>
015.
<!--
016.
.style2 {color: #999999}
017.
-->
018.
</style>
019.
020.
</head>
021.
022.
<body>
023.
<?
024.
include
(
'connect.php'
);
025.
$sql
=mysql_query(
"select product_id from product order by product_id desc limit 0,1"
);
026.
$a
=mysql_fetch_array(
$sql
);
027.
$id
=
$a
[0]+1;
028.
$num
=
strlen
(
$id
);
029.
switch
(
$num
){
030.
case
(1):
031.
$id
=
'00'
.
$id
;
032.
break
;
033.
default
:
034.
$id
=
'0'
.
$id
;
035.
break
;}
036.
session_start();
037.
echo
$_SESSION
[id];
038.
039.
040.
041.
042.
if
((
$_FILES
[
"file"
][
"type"
] ==
"image/pjpeg"
)
043.
&& (
$_FILES
[
"file"
][
"size"
] < 2000000))
044.
{
045.
if
(
$_FILES
[
"file"
][
"error"
] > 0)
046.
{
047.
echo
"Return Code: "
.
$_FILES
[
"file"
][
"error"
] .
"<br>"
;
048.
}
049.
else
050.
{
051.
move_uploaded_file(
$_FILES
[
"file"
][
"tmp_name"
],
"../images/auction/"
.
$_POST
[id].
".jpg"
);
052.
}
053.
}
054.
else
055.
{
056.
echo
'<center><br><br><br><br><img src="../images/'
.
$id
.
'.jpg" width="252" height="74" /></center>'
;
057.
echo
'<br><br><center><font size=2 color=red><b>กรุณา upload file รูปด้วยครับ</b></font></center><br><br>'
;
058.
?>
059.
060.
<?
die
();
061.
}
062.
063.
?>
064.
065.
<form action=
"product_add_DB.php"
method=
"post"
enctype=
"multipart/form-data"
name=
"form1"
id=
"form1"
>
066.
<table width=
"450"
border=
"1"
align=
"center"
cellpadding=
"0"
cellspacing=
"0"
>
067.
<tr>
068.
<td height=
"30"
colspan=
"2"
align=
"center"
bgcolor=
"#FFCC66"
><strong>เพิ่มสินค้า</strong></td>
069.
</tr>
070.
<tr>
071.
<td width=
"224"
align=
"center"
bgcolor=
"#FFCC99"
>รหัส</td>
072.
<td width=
"350"
bgcolor=
"#FFFFCC"
><?
echo
$id
; ?></td>
073.
</tr>
074.
<tr>
075.
<td height=
"30"
align=
"center"
bgcolor=
"#FFCC99"
>ชื่อ</td>
076.
<td bgcolor=
"#FFFFCC"
><input name=
"name"
type=
"text"
id=
"name"
value=
"<? echo $_POST[name];?>"
/></td>
077.
</tr>
078.
<tr>
079.
<td align=
"center"
bgcolor=
"#FFCC99"
>ราคา</td>
080.
<td bgcolor=
"#FFFFCC"
><input name=
"pr"
type=
"text"
id=
"pr"
maxlength=
"4"
value=
"<? echo $_POST[pr];?>"
/> <span
class
=
"style2"
>*บาท / กิโลกรัม</span></td>
081.
</tr>
082.
<tr>
083.
<td align=
"center"
bgcolor=
"#FFCC99"
>รูปภาพ</td>
084.
<td bgcolor=
"#FFFFCC"
><label>
085.
<img src=
"images/auction/<? echo $_POST[id];?>.JPG"
width=
"105"
height=
"125"
/>
086.
<br />
087.
<span
class
=
"style2"
> *ไฟล์รูปภาพสกุล .jpg เท่านั้น</span> </label></td>
088.
</tr>
089.
<tr>
090.
<td align=
"center"
bgcolor=
"#FFCC99"
>สรรพคุณ</td>
091.
<td bgcolor=
"#FFFFCC"
><label>
092.
<textarea name=
"detail"
id=
"detail"
cols=
"45"
rows=
"5"
value=
"<? echo $_POST[detail];?>"
></textarea>
093.
</label></td>
094.
</tr>
095.
<tr>
096.
<td colspan=
"2"
bgcolor=
"#FFCC66"
><center>
097.
<input name=
"id"
type=
"hidden"
value=
"<? echo $id;?>"
/>
098.
<input type=
"submit"
name=
"Submit2"
value=
"ยืนยัน"
/>
099.
</center></td>
100.
</tr>
101.
</table>
102.
</form>
103.
</body>
104.
</html>