<? include "chksession.php";?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>ร้านจำหน่ายปลาสวยงามและอุปกรณ์ทุกชนิด</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link href="../style.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="FCKeditor/fckeditor.js"></script> </head> <script> function check_number() { e_k=event.keyCode //if (((e_k < 48) || (e_k > 57)) && e_k != 46 ) { if (e_k != 13 && (e_k < 48) || (e_k > 57)) { event.returnValue = false; alert("กรอกเป็นตัวเลขเท่านั้น!"); } } function check(){ if(f1.product_name.value == ""){ alert("โปรดกรอกชื่อสินค้าครับ"); stop(); } if(f1.ref_type_id.value == "0"){ alert("โปรดกรอกประเภทสินค้าครับ"); stop(); } if(f1.product_detail.value == ""){ alert("โปรดกรอกรายละเอียดสินค้าครับ"); stop(); } if(f1. product_price .value == ""){ alert("โปรดกรอกราคาสินค้าครับ"); stop(); } if(f1.stock.value == ""){ alert("โปรดระบุจำนวนสินค้าครับ"); stop(); } { f1.submit(); } } </script> <body leftmargin=0 topmargin=0> <table width="780" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="17" background="images/bg_left.gif"><img src="images/bg_left.gif" width="17" height="16"></td> <td width="780" align=lift valign=top><table width="780" border="0" cellspacing="0" cellpadding="0"> <tr> <td align=lift valign=top> <? include "menu.php"; ?> </td> </tr> <tr> <td height="20" align=lift valign=top><table width="780" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="200" height="20" align=lift valign=top> <? include "menu_left.php"; ?> </td> <td width="580" align=lift valign=top><table width="550" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><div align="center"> <table width="550" border="0" cellpadding="0" cellspacing="0"> <tr> <td><p align="left" class="p"><strong>เพิ่มสินค้าใหม่</strong></p></td> </tr> <tr> <td><form name="form1" method="post" action="prd_add2.php" enctype="multipart/form-data" id="f1"> <table width="550" border="0" cellpadding="1" cellspacing="0" bordercolor="#eff2f3"> <tr> <td width="115"><p align="right" class="p">ชื่อสินค้า :</p></td> <td width="431"> <input name="product_name" type="text" id="product_name" size="50" maxlength="150" > <font color="#FF0000">*</font> </td> </tr> <tr> <td ><p align="right" class="p">ประเภทสินค้า :</p></td> <td > <select name ="ref_type_id" id"ref_type_id"> <option value = "0" > เลือกประเภทสินค้า</option> <? $price=$_POST[price]; $t="สนใจติดต่อ"; include("../connect.php"); $sql2 = "select * from type order by type_id asc" ; $result2 = mysql_db_query ($db,$sql2) ; while ($rs2 = mysql_fetch_array ($result2)) { $type_id = $rs2[type_id] ; $type_name = $rs2[type_name]; echo "<option value = '$type_id'> $type_name </option>" ; } ?> </select> <font color="#FF0000">*</font></td> </tr> <tr> <td align=lift valign=top><p align="right" class="p">รายละเอียดสินค้า :</p></td> <td > <textarea name="product_detail" rows="4" cols="40" id="product_detail"></textarea> <font color="#FF0000">*</font></td> </tr> <tr> <td ><p align="right" class="p">ราคาสินค้า :</p></td> <td ><p align="left" class="p"> <input type = "text" name="product_price" id="product_price" onkeypress= "check_number();" size = "20" maxlength="7"> <font color="#FF0000">* ไม่มี ให้ใส่ 0</font></p> </td> </tr> <tr> <td ><p align="right" class="p">จำนวนสินค้า :</p></td> <td > <input name = "stock" type = "text" id="stock" onkeypress= "check_number();" size = "20" maxlength="2"> <font color="#FF0000">*</font></td> </tr> <tr> <td width="115"><p align="right" class="p">รูปภาพสินค้า :</p></td> <td align="left" valign="top"><input type="file" name="file" /> <? if($hidAction == "Add") { //เช็คค่า hidAction ที่ส่งมาถ้าเท่ากับ Add ให้โปรแกรทำงานต่อ $date = date("U"); // สร้าเลข 10 หลักมาจากเวลาเพื่อนำไปเป็นชื่อรูปภาพ if($file != "") { $type = getimagesize($file); // หาประเภทของรูปภาพ if($type[2] == 1) { $picture = $date."_img.gif"; // เมื่อรูปเป็น .gif } else if($type[2] == 2) { $picture = $date."_img.jpg"; // เมื่อรูปเป็น .jpg } else { $picture = $date."_img.bmp"; // เมื่อรูปเป็น .bmp } copy($file, "picture/$picture"); // copy รูปไว้ในโฟลเดอร์ image chmod("picture/$picture", 0777); // ทำการ changmode } $host="localhost"; $db_username="root"; $db_password="1234"; $dbname="db_web"; //ชื่อฐานข้อมูล $connect = mysql_connect($host,$db_username,$db_password); if(!$connect){ echo "ไม่สามารถติดต่อฐานข้อมูลได้"; exit(); } $sql = "insert into picture (id, picture) values ('', '$picture') "; //เพิ่มข้อมูลลงดาต้าเบส โดยเก็บชื่อรูปไว้ $dbquery = mysql_db_query($dbname, $sql); } ?> <input name="hidAction" id="hidAction" type="hidden" value="Add"> </tr> <tr> <td ><p align="right" class="p">สถานะ :</p></td> <td ><p align="left" class="p"> <input type="radio" name="status" value="y"> แสดงหน้าแรก <input type="radio" name="status" value="n" checked> ไม่แสดงหน้าแรก </p></td> </tr> <tr> <td><div align="center"> </div></td> <td> <input type="button" name="Button" value=" ตกลง " onClick="check()"> <input type="reset" name="Reset" value="ยกเลิก"> </td> </tr> </table> </form></td> </tr> </table> </div></td> </tr> <tr> <td><p align="right" class="p"> <font color="#FF0000"> * โปรดกรอกข้อมูลที่มีเครื่องหมายให้ครบ</font></p></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td align=lift valign=top> <? include "button.php"; ?> </td> </tr> </table></td> <td width="17" background="images/bg_right.gif"><img src="images/bg_right.gif" width="17" height="16"></td> </tr> </table> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง