|
|
|
ต้องการบันทึกข้อมูลแต่อยู่ดีๆ บันทึกแล้วข้อมูลไม่เข้า ช่วยตรวจสอบโค้ดให้ทีค่ะ |
|
|
|
|
|
|
|
พอกดบันทึกแล้วข้อมูลมันไม่เพิ่มให้อ่ะค่ะ ลองแก้ๆดูแล้วก็ยังไม่ได้
ไม่รู้ว่าผิดตรงไหน ช่วยดูให้ทีค่ะ T^T
ขอบคุณค่ะ
หน้าเพิ่มข้อมูล
<?php
//require_once('Connections/myconnection.php');
include("staff_page.php");
//session_start();
//if(isset($_SESSION["Username"])){
//$sess_username=$_SESSION["Username"];
//}
//session_start();
//$sess_Username="999999";
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO data_customers (ctm_name, ctm_surname, ctm_product, ctm_model, ctm_tel, ctm_date, ctm_fix, ) VALUES (%s, %s, %s, %s, %s, %s, %s,)",
GetSQLValueString($_POST['ctm_name'], "text"),
GetSQLValueString($_POST['ctm_surname'], "text"),
GetSQLValueString($_POST['ctm_product'], "text"),
GetSQLValueString($_POST['ctm_model'], "text"),
GetSQLValueString($_POST['ctm_tel'], "int"),
GetSQLValueString($_POST['ctm_date'], "date"),
GetSQLValueString($_POST['ctm_fix'], "text"));
//mysql_select_db($database_AddDataCustomers, $AddDataCustomers);
//$Result1 = mysql_query($insertSQL, $AddDataCustomers) or die(mysql_error());
$insertGoTo = "data-table.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!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>After Sale Service</title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table border="0" align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td align="center"><p>เพิ่มข้อมูลใหม่</p></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">ชื่อ:</td>
<td><input type="text" name="ctm_name" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">นามสกุล:</td>
<td><input type="text" name="ctm_surname" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">ยี่ห้อมือถือ:</td>
<td>
<select name="ctm_product" id="ctm_product">
<?php
$strSQL = "SELECT * FROM add_product";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["brand"];?>"><?=$objResuut["brand"];?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">รุ่น:</td>
<td>
<select name="ctm_model" id="ctm_model">
<?php
$strSQL = "SELECT * FROM add_product";
$objQuery = mysql_query($strSQL);
while($objResuut = mysql_fetch_array($objQuery))
{
?>
<option value="<?=$objResuut["model"];?>"><?=$objResuut["model"];?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">เบอร์ติดต่อ:</td>
<td>
<input type="text" name="ctm_tel" value="" size="32" />
</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">วันที่มาซ่อม(ป-ด-ว):</td>
<td>
<input type="text" name="ctm_date" value="<?php echo date('Y-m-d'); ?>" size="32" />
</td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">บริการที่เข้ารับ:</td>
<td><select name="ctm_fix" id="ctm_fix">
<option value="case1">case1</option>
<option value="case2">case2</option>
<option value="case3">case3</option>
</select></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><center><input type="submit" value="บันทึก" />
<input type="reset" name="resend" id="resend" value="ล้างข้อมูลทั้งหมด" />
</center></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2013-11-15 23:21:43 |
By :
aorplus |
View :
734 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo $insertSQL ออกมาดูครับ
|
|
|
|
|
Date :
2013-11-16 00:30:55 |
By :
mangkunzo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอา comment บรรทัดที่ 63 ออกครับ
มันไม่ทำงาน
// $Result1 = mysql_query($insertSQL, $AddDataCustomers) or die(mysql_error());
|
|
|
|
|
Date :
2013-11-16 09:16:18 |
By :
james.born |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ความลับเก็บงำไว้ที่สองบรรทัดนี้
//mysql_select_db($database_AddDataCustomers, $AddDataCustomers)
//$Result1 = mysql_query($insertSQL, $AddDataCustomers) or die(mysql_error());
|
|
|
|
|
Date :
2013-11-16 14:05:10 |
By :
{Cyberman} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|