ดูโค้ดให้หน่อยค่ะ มันเข้าแต่ else ไม่เข้า if เลย มือใหม่หัดเขียน ชี้แนะด้วยค่ะ
โพสต์แล้ว: 12/10/2012 3:54 pm
1. ไฟล์ add.php
<form id="form2" name="form2" method="post" action="add_product1.php" enctype="multipart/form-data">
<table width="485" border="0">
<tr>
<th width="86" scope="col">รหัสสินค้า</th>
<td width="389"><label for="num_pro"></label>
<input type="text" name="num_pro" id="num_pro" />
</tr>
<tr>
<th scope="row"><span class="style23">ชื่อสินค้า</span></th>
<td><input name="name_pic" type="text" id="name_pic" size="45" /></td>
</tr>
<tr>
<th scope="row"><span class="style23">ราคา</span></th>
<td><input type="text" name="price" id="price" /></td>
</tr>
<tr>
<th scope="row"><span class="style23">ภาพสินค้า</span></th>
<td><input name="fileupload " type="file" id="fileupload " size="45" /></td>
</tr>
<tr>
<th scope="row"> </th>
<td><input type="submit" name="Submit" id="Submit" value="เพิ่มสินค้า" />
<input type="submit" name="reset" id="reset" value="ยกเลิก" /></td>
</tr>
</table>
</form>
2. ไฟล์ add1.php
[/color]
<form id="form2" name="form2" method="post" action="add_product1.php" enctype="multipart/form-data">
<table width="485" border="0">
<tr>
<th width="86" scope="col">รหัสสินค้า</th>
<td width="389"><label for="num_pro"></label>
<input type="text" name="num_pro" id="num_pro" />
</tr>
<tr>
<th scope="row"><span class="style23">ชื่อสินค้า</span></th>
<td><input name="name_pic" type="text" id="name_pic" size="45" /></td>
</tr>
<tr>
<th scope="row"><span class="style23">ราคา</span></th>
<td><input type="text" name="price" id="price" /></td>
</tr>
<tr>
<th scope="row"><span class="style23">ภาพสินค้า</span></th>
<td><input name="fileupload " type="file" id="fileupload " size="45" /></td>
</tr>
<tr>
<th scope="row"> </th>
<td><input type="submit" name="Submit" id="Submit" value="เพิ่มสินค้า" />
<input type="submit" name="reset" id="reset" value="ยกเลิก" /></td>
</tr>
</table>
</form>
2. ไฟล์ add1.php
โค้ด: เลือกทั้งหมด
<?
$num_pro= $_POST['num_pro'];
$name_pic = $_POST['name_pic'];
$price = $_POST['price'];
$fileupload = $_POST['pic_pro'];
@mysql_connect("localhost", "root", "1234") or die (mysql_error());
@mysql_select_db ("furniture");
if($name_pic=="")
@mysql_query($sql) or die (mysql_error());
{
if(move_uploaded_file($_FILES["fileupload "]["tmp_name"],"product/$fileupload ".$_FILES["fileupload "]["name"]))
{
echo"complete";
$pro_pic = $_FILES["fileupload "]["name"];
$sql = "Insert into product (id_pic,num_pro,name_pic,price,fileupload) values('','$num_pro','$name_pic','$price','$fileupload ');";
}
else
{
echo"NO";
}
}
?>