<?php include("../inc/connect.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <form action="addsave.php" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table width="300" border="1" cellspacing="1"> <tr> <th colspan="2" bgcolor="#FFFF66" scope="row">Addproduct</th> </tr> <tr> <th width="89" scope="row">Name</th> <td width="198"><input type="text" name="name" id="name" /></td> </tr> <tr> <th scope="row">Detail</th> <td><textarea name="detail" id="detail" cols="45" rows="5"></textarea></td> </tr> <tr> <th scope="row">Price</th> <td><input type="text" name="price" id="price" /></td> </tr> <tr> <th scope="row"><p>Category</p></th> <td><select name="c_id" id="c_id"> <?php $sqlc = "select * from category order by c_id asc"; $queryc = mysql_query($sqlc)or die (mysql_error()); $numc = mysql_num_rows($queryc); for($i=1;$i<=$numc;$i++) { $rowc = mysql_fetch_array($queryc); ?> <option value="<?php echo $rowc['c_id']?>"><?php echo $rowc['c_name'] ?></option> <? } ?> </select></td> </tr> <tr> <th scope="row">Image</th> <td><input type="file" name="attach" id="attach" /></td> </tr> <tr> <th colspan="2" bgcolor="#FFFF66" scope="row"><input type="submit" name="Submit" id="Submit" value="Submit" /></th> </tr> </table> </form> </body> </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php include("../inc/connect.php"); $name =$_POST['name']; $detail =$_POST['detail']; $price =$_POST['price']; $c_id =$_POST['c_id']; echo "$name<br>$detail<br>$price<br>$c_id<br>"; IF(EMPTY($name)||EMPTY($detail)||EMPTY($price)) { EXIT("<script>alert('data not empty');history.back();</script>"); //Java script } if(!is_numeric($price)) { exit("<script>alert('price is number only');history.back();</script>"); } $attach = $_FILES['attach']; if($attach['error']==o) { $fileinfo = pathinfo($attach['name']); $filetype = strtolower ($fileinfo['extension']); $type = array('gif','jpg','png'); if(in_array($filetype,$type)) { $newname = time().".$filetype"; move_uploaded_file($attach['tmp_name'],"../img/$newname"); }else { exit("<script>alert('Please check file');history.back();</script>"); } } $sql = "insert into product values(null,'$name','$detail','$price','$newname','$c_id')"; mysql_query($sql)or die (mysql_error()); echo "<script>window.location='index.php';</script>"; ?> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง