|
 |
|
พี่ค่ะ ใครก็ได้ช่วยตรวจสอบที นั่งงมมาสองวันละ Insert ข้อมูลไม่ได้ |
|
 |
|
|
 |
 |
|
พี่ค่ะ ใครก็ได้ช่วยตรวจสอบที นั่งงมมาสองวันละ Insert ข้อมูลไม่ได้
นี้ add_product.php
Code (PHP)
<?php
session_start();
// ตรวจสอบการ login
if (!isset($_SESSION["session_user"])){
header("Location:admin_login.php");
}
// =========================Start Session และทำการเรียก Function ติดต่อฐานข้อมูล
require_once("connections/StartConnect.php");
//=========== กรณีลบรายการสินค้า
if($_GET["Action"]=="Delete")
{
//=========== ลบข้อมูล
$sql_del= "delete from product where ProductID='".$_GET["ProductID"]."'";
$dbquery_del = mysql_query($sql_del);
//=========== ลบรูปเล็กและรูปใหญ่
@unlink("../pic/$_GET[file1]");
@unlink("../pic/$_GET[file2]");
echo"<script language='JavaScript'>";
echo"alert ('Delete completed.');";
echo"window.location='product.php';";
echo"</script>";
}
?>
<!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>
<title>TheSite</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style3 {font-size: 18px}
.style4 {font-size: 12px}
-->
</style>
<!-- javascript title ber แบบวิ่งได้ -->
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var scrl = "ความอร่อยที่คุณเลือกได้ ::. ";
function scrlsts() {
scrl = scrl.substring(1, scrl.length) + scrl.substring(0, 1);
document.title = scrl;
setTimeout("scrlsts()", 300);
}
// End -->
</script>
<!-- จบส่วนของ javascript title bar -->
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<!-- ส่วนเพิ่มของ java script title bar -->
<BODY onLoad="scrlsts()">
<!-- จบส่วน java script -->
<div id="wrapper">
<div id="left_column">
<div id="site_title"></div>
<!-- end of site_title -->
<div id="sidebar">
<div class="service_section">
<?php require_once("admin_menu.html");?>
</div>
</div>
</div>
<!-- end of left column -->
<div id="right_column">
<div id="menu">
</div>
<!-- end of menu -->
<div id="content_wrapper">
<div id="content">
<h2 align="center" class="style3">.:: เพิ่มสินค้าใหม่ ::.</h2>
<table width="98%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#2D81FF" class="table22">
<tr><td><form action="add_product_check.php" method="post">
<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td width="35%"><div align="right">หมวดสินค้า :<span class="FontMsg">**</span></div></td>
<td width="65%">
<select name="CatID">
<option value=""> ----- คลิก ----- </option>
<?
//=========== แสดงหมวดหมู่
$sql = "select * from category order by CatID asc";
$dbquery = mysql_query($sql);
$num = mysql_num_rows($dbquery);
for($i=1;$i<=$num;$i++)
{
$res = mysql_fetch_array($dbquery)
?>
<option value="<?=$res['CatID'];?>"><?=$res['CategoryName'];?></option>
<?
}
?>
</select></td>
</tr>
<tr>
<td><div align="right">ชื่อสินค้า :<span class="FontMsg">**</span></div></td>
<td><label><input name="ProductName" type="text" id="ProductName" size="50" /></label></td>
</tr>
<tr>
<td><div align="right">สินค้าโปรโมชั่น :<span class="FontMsg">**</span></div></td>
<td>
<input name="Promotion" type="radio" value="Yes" >
ใช่
<input name="Promotion" type="radio" value="No">
ไม่ใช่</td>
</tr>
<tr>
<td><div align="right">สินค้าใหม่ :<span class="FontMsg">**</span></div></td>
<td>
<input name="New" type="radio" value="Yes">
ใช่
<input name="New" type="radio" value="No">
ไม่ใช่</td>
</tr>
<tr>
<td><div align="right">ราคาปกติ :<span class="FontMsg">**</span></div></td>
<td><label><input type="text" name="PriceNormal" id="PriceNormal" /></label></td>
</tr>
<tr>
<td><div align="right">ราคาพิเศษ :<span class="FontMsg">**</span></div></td>
<td><label><input type="text" name="Price" id="Price" /></label></td>
</tr>
<tr>
<td><div align="right">ค่าจัดส่ง :<span class="FontMsg">**</span></div></td>
<td><label><input type="text" name="PriceSend" id="PriceSend" /></label></td>
</tr>
<tr>
<td><div align="right">รูปภาพ :<span class="FontMsg">**</span></div></td>
<td><input name="Picture" type="file"></td>
</tr>
<tr>
<td><div align="right">รายละเอียด :<span class="FontMsg">**</span></div></td>
<td><label><textarea name="Description" id="Description" cols="45" rows="5"></textarea></label></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><label>
<input type="submit" name="save" id="save" value="บันทึก " />
<input type="reset" name="reset" id="button3" value="ยกเลิก " />
</label></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td> </td>
</tr>
</table>
</form>
</td></tr>
</table>
</div>
</div>
<!-- end of content_wrapper -->
<div id="content_bottom"></div>
</div>
</div>
<!-- end of wrapper -->
<div id="footer_wrapper">
<div id="footer">
</div>
<!-- end of footer -->
</div>
<!-- end of footer_wrapper -->
</body>
</html>
นี้ add_product_check.php
<?php
session_start();
// ตรวจสอบการ login
if (!isset($_SESSION["session_user"])){
header("Location:admin_login.php");
}
// =========================Start Session และทำการเรียก Function ติดต่อฐานข้อมูล
require_once("connections/StartConnect.php");
$CatID =$_POST['CatID'];
$Pro_ID =$_POST['ProductID'];
$ProductName=$_POST['ProductName'];
$Description=$_POST['Description'];
$Promotion =$_POST['Promotion'];
$New =$_POST['New'];
$PriceNormal=$_POST['PriceNormal'];
$Price =$_POST['Price'];
$PriceSend =$_POST['PriceSend'];
$Picture =$_FILES['Picture'];
$imageinfo =pathinfo($Picture['name']);
if(isset($HTTP_POST_VARS["save"])){
if(empty($CatID)||empty($ProductName)||empty($Description)||empty($Promotion)||empty($New)||empty($PriceNormal)||empty($Price)||empty($PriceSend)||empty($Picture))
{
echo "<script>";
echo "alert('Please check gain.');";
echo "window.history.go(-1);";
echo "</script>";
}else{
// ตรวจสอบไฟล์ที่แนบมา
if($Picture['size']!=0&& $imageinfo['extension']!='jpg'&& $imageinfo['extension']!='gif')
{
echo "<script>";
echo "alert('แนบไฟล์ .gif หรือ .jpg เท่านั้น');";
echo "window.history.go(-1);";
echo "</script>";
exit();
}
// นำคำสั่งมาประมวลผล
$ProductCode=str_pad($Pro_ID,6, "0", STR_PAD_LEFT);
$sql="INSERT INTO product (CatID,ProductCode,ProductName,Description,Promotion,New,PriceNormal,Price,PriceSend) values('$CatID','$ProductCode','$ProductName','$Description','$Promotion','$New','$PriceNormal','$Price','$PriceSend')";
$res=mysql_query($sql);
// ย้ายรูปเก็บไว้ในตำแหน่งที่ต้องการ
if($Picture['size']!=0)
{
$imagename=mysql_insert_id().".jpg";
move_uploaded_file($Picture['tmp_name'],"../pic/$imagename");
}
}
}
mysql_close();
echo "<script>";
echo "window.location='product.php';";
echo "</script>";
?>
Tag : PHP, MySQL

|
|
 |
 |
 |
 |
Date :
2010-09-26 19:25:11 |
By :
annmoodom |
View :
829 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โทดทีค่ะมี 2 ไฟล์
add_product.php
Code (PHP)
<?php
session_start();
// ตรวจสอบการ login
if (!isset($_SESSION["session_user"])){
header("Location:admin_login.php");
}
// =========================Start Session และทำการเรียก Function ติดต่อฐานข้อมูล
require_once("connections/StartConnect.php");
//=========== กรณีลบรายการสินค้า
if($_GET["Action"]=="Delete")
{
//=========== ลบข้อมูล
$sql_del= "delete from product where ProductID='".$_GET["ProductID"]."'";
$dbquery_del = mysql_query($sql_del);
//=========== ลบรูปเล็กและรูปใหญ่
@unlink("../pic/$_GET[file1]");
@unlink("../pic/$_GET[file2]");
echo"<script language='JavaScript'>";
echo"alert ('Delete completed.');";
echo"window.location='product.php';";
echo"</script>";
}
?>
<!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>
<title>TheSite</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="style/style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style3 {font-size: 18px}
.style4 {font-size: 12px}
-->
</style>
<!-- javascript title ber แบบวิ่งได้ -->
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var scrl = "ความอร่อยที่คุณเลือกได้ ::. ";
function scrlsts() {
scrl = scrl.substring(1, scrl.length) + scrl.substring(0, 1);
document.title = scrl;
setTimeout("scrlsts()", 300);
}
// End -->
</script>
<!-- จบส่วนของ javascript title bar -->
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<body>
<!-- ส่วนเพิ่มของ java script title bar -->
<BODY onLoad="scrlsts()">
<!-- จบส่วน java script -->
<div id="wrapper">
<div id="left_column">
<div id="site_title"></div>
<!-- end of site_title -->
<div id="sidebar">
<div class="service_section">
<?php require_once("admin_menu.html");?>
</div>
</div>
</div>
<!-- end of left column -->
<div id="right_column">
<div id="menu">
</div>
<!-- end of menu -->
<div id="content_wrapper">
<div id="content">
<h2 align="center" class="style3">.:: เพิ่มสินค้าใหม่ ::.</h2>
<table width="98%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#2D81FF" class="table22">
<tr><td><form action="add_product_check.php" method="post">
<table width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td width="35%"><div align="right">หมวดสินค้า :<span class="FontMsg">**</span></div></td>
<td width="65%">
<select name="CatID">
<option value=""> ----- คลิก ----- </option>
<?
//=========== แสดงหมวดหมู่
$sql = "select * from category order by CatID asc";
$dbquery = mysql_query($sql);
$num = mysql_num_rows($dbquery);
for($i=1;$i<=$num;$i++)
{
$res = mysql_fetch_array($dbquery)
?>
<option value="<?=$res['CatID'];?>"><?=$res['CategoryName'];?></option>
<?
}
?>
</select></td>
</tr>
<tr>
<td><div align="right">ชื่อสินค้า :<span class="FontMsg">**</span></div></td>
<td><label><input name="ProductName" type="text" id="ProductName" size="50" /></label></td>
</tr>
<tr>
<td><div align="right">สินค้าโปรโมชั่น :<span class="FontMsg">**</span></div></td>
<td>
<input name="Promotion" type="radio" value="Yes" >
ใช่
<input name="Promotion" type="radio" value="No">
ไม่ใช่</td>
</tr>
<tr>
<td><div align="right">สินค้าใหม่ :<span class="FontMsg">**</span></div></td>
<td>
<input name="New" type="radio" value="Yes">
ใช่
<input name="New" type="radio" value="No">
ไม่ใช่</td>
</tr>
<tr>
<td><div align="right">ราคาปกติ :<span class="FontMsg">**</span></div></td>
<td><label><input type="text" name="PriceNormal" id="PriceNormal" /></label></td>
</tr>
<tr>
<td><div align="right">ราคาพิเศษ :<span class="FontMsg">**</span></div></td>
<td><label><input type="text" name="Price" id="Price" /></label></td>
</tr>
<tr>
<td><div align="right">ค่าจัดส่ง :<span class="FontMsg">**</span></div></td>
<td><label><input type="text" name="PriceSend" id="PriceSend" /></label></td>
</tr>
<tr>
<td><div align="right">รูปภาพ :<span class="FontMsg">**</span></div></td>
<td><input name="Picture" type="file"></td>
</tr>
<tr>
<td><div align="right">รายละเอียด :<span class="FontMsg">**</span></div></td>
<td><label><textarea name="Description" id="Description" cols="45" rows="5"></textarea></label></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><label>
<input type="submit" name="save" id="save" value="บันทึก " />
<input type="reset" name="reset" id="button3" value="ยกเลิก " />
</label></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td> </td>
</tr>
</table>
</form>
</td></tr>
</table>
</div>
</div>
<!-- end of content_wrapper -->
<div id="content_bottom"></div>
</div>
</div>
<!-- end of wrapper -->
<div id="footer_wrapper">
<div id="footer">
</div>
<!-- end of footer -->
</div>
<!-- end of footer_wrapper -->
</body>
</html>
ส่วนนี้ add_product_check.php
Code (PHP)
<?php
session_start();
// ตรวจสอบการ login
if (!isset($_SESSION["session_user"])){
header("Location:admin_login.php");
}
// =========================Start Session และทำการเรียก Function ติดต่อฐานข้อมูล
require_once("connections/StartConnect.php");
$CatID =$_POST['CatID'];
$Pro_ID =$_POST['ProductID'];
$ProductName=$_POST['ProductName'];
$Description=$_POST['Description'];
$Promotion =$_POST['Promotion'];
$New =$_POST['New'];
$PriceNormal=$_POST['PriceNormal'];
$Price =$_POST['Price'];
$PriceSend =$_POST['PriceSend'];
$Picture =$_FILES['Picture'];
$imageinfo =pathinfo($Picture['name']);
if(isset($HTTP_POST_VARS["save"])){
if(empty($CatID)||empty($ProductName)||empty($Description)||empty($Promotion)||empty($New)||empty($PriceNormal)||empty($Price)||empty($PriceSend)||empty($Picture))
{
echo "<script>";
echo "alert('Please check gain.');";
echo "window.history.go(-1);";
echo "</script>";
}else{
// ตรวจสอบไฟล์ที่แนบมา
if($Picture['size']!=0&& $imageinfo['extension']!='jpg'&& $imageinfo['extension']!='gif')
{
echo "<script>";
echo "alert('แนบไฟล์ .gif หรือ .jpg เท่านั้น');";
echo "window.history.go(-1);";
echo "</script>";
exit();
}
// นำคำสั่งมาประมวลผล
$ProductCode=str_pad($Pro_ID,6, "0", STR_PAD_LEFT);
$sql="INSERT INTO product (CatID,ProductCode,ProductName,Description,Promotion,New,PriceNormal,Price,PriceSend) values('$CatID','$ProductCode','$ProductName','$Description','$Promotion','$New','$PriceNormal','$Price','$PriceSend')";
$res=mysql_query($sql);
// ย้ายรูปเก็บไว้ในตำแหน่งที่ต้องการ
if($Picture['size']!=0)
{
$imagename=mysql_insert_id().".jpg";
move_uploaded_file($Picture['tmp_name'],"../pic/$imagename");
}
}
}
mysql_close();
echo "<script>";
echo "window.location='product.php';";
echo "</script>";
?>
|
 |
 |
 |
 |
Date :
2010-09-26 19:28:40 |
By :
annmoodom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มีเออเรอฟ้องหรือครับ
|
 |
 |
 |
 |
Date :
2010-09-26 19:57:10 |
By :
narubet |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีค่ะ Please check gain. ฟ้องเงื่อนไขแรกค่ะ เหมือนเราใส่ข้อความไม่ครบแต่เราใส่ครบแล้วนะคะ หาไม่เจอสักที ช่วยทีค่ะ
|
 |
 |
 |
 |
Date :
2010-09-26 22:36:12 |
By :
annmoodom |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองใส่ echo ค่าต่างๆมาดูก่อนแล้ว commect ส่วนอื่นๆไว้ครับเช่น
Code (PHP)
$CatID =$_POST['CatID'];
$Pro_ID =$_POST['ProductID'];
$ProductName =$_POST['ProductName'];
$Description =$_POST['Description'];
$Promotion =$_POST['Promotion'];
$New =$_POST['New'];
$PriceNormal =$_POST['PriceNormal'];
$Price =$_POST['Price'];
$PriceSend =$_POST['PriceSend'];
$Picture =$_FILES['Picture'];
$imageinfo =pathinfo($Picture['name']);
echo $CatID ;
/*
if(){}
*/
|
 |
 |
 |
 |
Date :
2010-09-26 22:48:10 |
By :
dekkuza |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|