ช่วยตรวจดู code ให้หน่อยครับ แก้ไขข้อมูลแล้ว มันไม่บันทึกลง ฐานข้อมูลครับ... /////////แก้ได้แล้ว ครับขอบคุณทุกคนครับ//////////
ช่วยตรวจดู code ให้หน่อยครับ แก้ไขข้อมูลแล้ว มันไม่บันทึกลงแต่ ฐานข้อมูลครับ...
ส่วนของ member_edit.php
Code (PHP)
<?php
#### สคริ๊ปนี้ใช้ในการเช็ค ว่าล็อกอินหรือยัง ให้นำสคริ๊ปนี้ไปไว้ที่หน้าที่คุณต้องการให้เช็ค ####
session_start() ;
if (!isset($_SESSION['login_true'])) {
header("Location: index.php");
exit;
}
### จบการเช็ค ###
?>
<html>
<head>
<title>:: ระบบสมาชิก :: แก้ไขข้อมูลส่วนตัว</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<STYLE type=text/css>
A:link { color: #000000; text-decoration:none}
A:visited {color: #000000; text-decoration: none}
A:hover {color: red; text-decoration: none}
.style13 {font-size: 14px}
.style18 {color: #FF0000}
.style20 {font-family: Arial, Helvetica, sans-serif}
.style21 {font-family: Arial, Helvetica, sans-serif; color: #000000;}
.style3 {font-family: "MS Sans Serif", }
a:active {
color: #FF9900;
}
.style23 {font-size: 12px}
.style24 {font-family: "MS Sans Serif",; font-size: small; }
.style25 {font-size: small; }
.style26 {font-family: "MS Sans Serif",; font-size: small; color: #FF0000; }
</STYLE>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="500" border="0" align="center" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="1186" height="592" valign="top"><div align="center">
<div align="left"><span class="style3">
<?php
include("config.inc.php") ;
mysql_select_db($db) ;
$result = mysql_query("select * from member where user='$_SESSION[login_true]'") or die ("Err Can not to result") ;
$dbarr = mysql_fetch_array($result) ;
?>
<span class="style23"> <a href="../Index.html">หน้าหลัก</a> >จัดการบัญชี</span></span></div>
<table id="Table_01" width="750" height="33" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td rowspan="2"><img src="images/H_01.gif" width="85" height="33" alt=""></td>
<td width="180" height="19" valign="top"><table width="100%" height="27" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="180" height="19" valign="bottom"><font size="2" face="MS Sans Serif, Tahoma, sans-serif"> <?php echo $dbarr['name'] ; ?></font></td>
</tr>
</table></td>
<td rowspan="2"><img src="images/H_03.gif" alt="" width="485" height="33" border="0" usemap="#Map"></td>
</tr>
<tr>
<td><img src="images/H_04.gif" width="180" height="6" alt=""></td>
</tr>
</table>
<map name="Map">
<area shape="rect" coords="7,11,60,27" href="member_detail.php">
<area shape="rect" coords="76,13,150,27" href="member_corner.php">
<area shape="rect" coords="169,12,273,27" href="member_edit.php">
<area shape="rect" coords="292,12,381,27" href="change_pwd.php">
<area shape="rect" coords="399,11,477,27" href="logout.php">
</map>
<!-- End ImageReady Slices -->
<table width="580" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><form name="checkForm" action="member_edit_add.php" method="post" onSubmit="return check2();">
<br>
<div align="center">
<table width="509" border="0" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" class="style13"><br>
<img src="../images/icon-list[1].gif" width="11" height="11"> <font color="#FF3300" size="3" face="MS Sans Serif, Tahoma, sans-serif"><u>แก้ไขข้อมูลส่วนตัวของคุณ<br>
<br>
<br>
</u></font></td>
<td width="120" rowspan="2" class="style13"><div align="center"><span class="style3"><font size="2">หมายเลขสมาชิก<br>
<u><b><?php echo $dbarr['member_id'] ; ?></b></u></font></span></div> <div align="center"></div></td>
</tr>
<tr>
<td width="95" class="style13"><div align="right" class="style24">ชื่อ </div></td>
<td width="294" class="style25"><span class="style3">
<input name="name2" type="text" size="30" value="<?php echo "$dbarr[name]" ; ?>">
<span class="style18"> ** </span></span> <div align="right" class="style3"></div></td>
</tr>
<tr>
<td class="style13"><div align="right" class="style24">นามสกุล </div></td>
<td class="style13"><div align="left" class="style24">
<input name="name22" type="text" size="30" value="<?php echo "$dbarr[lastname]" ; ?>">
<span class="style18">**</span></div></td>
<td class="style13"><span class="style3"></span></td>
</tr>
<tr>
<td class="style13"><div align="right" class="style24"> ชื่อองค์กร </div></td>
<td class="style13"><div align="left" class="style24">
<input name="name222" type="text" size="30" value="<?php echo "$dbarr[organization]" ; ?>">
</div></td>
<td class="style13"><span class="style3"></span></td>
</tr>
<tr>
<td class="style13"><div align="right" class="style24">อีเมล์ </div></td>
<td class="style13"><div align="left" class="style24">
<input name="name223" type="text" size="30" value="<?php echo "$dbarr[email]" ; ?>">
<span class="style18">**</span></div></td>
<td class="style13"><span class="style3"></span></td>
</tr>
<tr>
<td class="style13"><div align="right" class="style24">ที่อยู่ </div></td>
<td class="style13"><div align="left" class="style24">
<input name="name224" type="text" size="30" value="<?php echo "$dbarr[address]" ; ?>">
<span class="style18"> **</span></div></td>
<td class="style13"><span class="style3"></span></td>
</tr>
<tr>
<td class="style13"><div align="right" class="style24">ที่อยู่(เพิ่มเติม) </div></td>
<td class="style13"><div align="left" class="style24">
<input name="name225" type="text" size="30" value="<?php echo "$dbarr[address2]" ; ?>">
</div></td>
<td class="style13"><span class="style3"></span></td>
</tr>
<tr>
<td class="style13"><div align="right" class="style24">อำเภอ/เขต </div></td>
<td class="style13"><div align="left" class="style24">
<input name="name226" type="text" size="30" value="<?php echo "$dbarr[district]" ; ?>">
<span class="style18"> **</span></div></td>
<td class="style13"><span class="style3"></span></td>
</tr>
<tr>
<td class="style13"><div align="right" class="style24">จังหวัด </div></td>
<td class="style13"><div align="left" class="style24">
<input name="name227" type="text" size="30" value="<?php echo "$dbarr[province]" ; ?>">
<span class="style18"> **</span></div></td>
<td class="style13"><span class="style3"></span></td>
</tr>
<tr>
<td class="style13"><div align="right" class="style24">รหัสไปรษณีย์ </div></td>
<td class="style13"><div align="left" class="style26">
<input name="name228" type="text" size="30" value="<?php echo "$dbarr[zipcode]" ; ?>">
**</div></td>
<td class="style13"><span class="style3"></span></td>
</tr>
<tr>
<td class="style13"><div align="right" class="style24"> เบอร์โทรศัพท์ </div></td>
<td class="style13"><div align="left" class="style24">
<input name="name229" type="text" size="30" value="<?php echo "$dbarr[phone]" ; ?>">
<span class="style18"> **</span></div></td>
<td class="style13"><span class="style3"></span></td>
</tr>
</table>
<br>
</div>
<div align="center"><br>
<input name="member_id" type="hidden" id="member_id" value="<?php echo $dbarr['member_id'] ; ?>">
<input type="submit" name="Submit2" value="บันทึกการเปลี่ยนแปลง"></div>
<script language="javascript">
function check() {
if(document.checkForm.name.value=="") {
alert("กรุณากรอก ชื่อด้วยครับ") ;
document.checkForm.name.focus() ;
return false ;
}
else if(document.checkForm.lastname.value=="") {
alert("กรุณากรอก นามสกุลด้วยครับ") ;
document.checkForm.lastname.focus() ;
return false ;
}
else if(document.checkForm.email.value=="") {
alert("กรุณากรอกอีเมล์ด้วยนะครับ") ;
return false ;
}
else if(checkForm.email.value.indexOf('@')==-1) {
alert("อีเมล์ของคุณไม่ถูกต้องครับ") ;
document.checkForm.email.focus() ;
return false ;
}
else if(checkForm.email.value.indexOf('.')==-1) {
alert("อีเมล์ของคุณไม่ถูกต้องครับ") ;
document.checkForm.email.focus() ;
return false ;
}
else if(document.checkForm.address.value=="") {
alert("กรุณากรอกที่อยู่") ;
document.checkForm.address.focus() ;
return false ;
}
else if(document.checkForm.district.value=="") {
alert("กรุณากรอก เขตหรืออำเภอ") ;
document.checkForm.district.focus() ;
return false ;
}
else if(document.checkForm.province.value=="") {
alert("กรุณากรอก จังหวัด") ;
document.checkForm.province.focus() ;
return false ;
}
else if(document.checkForm.zipcode.value=="") {
alert("กรุณากรอก รหัสไปรษณีย์") ;
document.checkForm.zipcode.focus() ;
return false ;
}
else if(isNaN(document.checkForm.zipcode.value)) {
alert("รหัสไปรสณีย์ต้องเป็นตัวเลขครับ") ;
document.checkForm.zipcode.focus() ;
return false ;
}
else if(document.checkForm.phone.value=="") {
alert("กรุณากรอก เบอร์โทรศัพท์") ;
document.checkForm.phone.focus() ;
return false ;
}
else if(isNaN(document.checkForm.phone.value)) {
alert("เบอร์โทรศัพท์ต้องเป็นตัวเลขครับ") ;
document.checkForm.phone.focus() ;
return false ;
}
else
return true ;
}
</script>
</form><br>
<center>
</center> </td>
</tr>
</table>
<p> </p>
</div></td>
</tr>
</table>
</body>
</html>
ส่วนของmember_edit_add.php
Code (PHP)
<?php
#### สคริ๊ปนี้ใช้ในการเช็ค ว่าล็อกอินหรือยัง ####
session_start() ;
if (!isset($_SESSION['login_true'])) {
header("Location: index.php");
exit;
}
### จบ ###
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<title>:: ผลการแก้ไขข้อมูลส่วนตัว ::</title>
</head>
<body>
<?php
include("config.inc.php") ;
/* add by kergrit(redthird.com) for compatible global variable off/on php.ini */
$name = $_POST['name'];
$lastname = $_POST['lastname'];
$organization = $_POST['organization'];
$address = $_POST['address'];
$address2 = $_POST['address2'];
$district = $_POST['district'];
$province = $_POST['province'];
$zipcode = $_POST['zipcode'];
$phone = $_POST['phone'];
$Submit2 = $_POST['Submit2'];
$member_id = $_POST['member_id'];
/* end of add */
$signup = date("j/n/").(date("Y")+543) ;
$name = htmlspecialchars($name) ;
$address = htmlspecialchars($address) ;
$zipcode = htmlspecialchars($zipcode) ;
$phone = htmlspecialchars($phone) ;
$sql[0] = "update member set name='$name' where member_id='$member_id' ";
$sql[1]= "update member set lastname='$lastname' where member_id='$member_id' ";
$sql[2] = "update member set organization='$organization' where member_id='$member_id' ";
$sql[3] = "update member set address='$address' where member_id='$member_id' ";
$sql[4] = "update member set address2='$address2' where member_id='$member_id' ";
$sql[5] = "update member set district='$district' where member_id='$member_id'";
$sql[6] = "update member set province='$province' where member_id='$member_id' ";
$sql[7] = "update member set zipcode='$zipcode' where member_id='$member_id' ";
$sql[8] = "update member set phone='$phone' where member_id='$member_id' ";
for($i=0;$i<9;$i++) {
$result = mysql_query($sql[$i]) or die("Err program") ;
}
if($result) {
echo "<br><br><center><font size=\"3\" face='MS Sans Serif'><b>รายละเอียดของคุณ ได้ถูกบันทึกใหม่แล้วครับ</b></font></center>" ;
echo "<meta http-equiv='refresh' content='4; url=member_detail.php'>" ;
}
?>
</body>
</html>
Tag : - - - -
Date :
2010-07-18 01:54:20
By :
aofza704
View :
980
Reply :
4
Code (PHP)
$result = mysql_query($sql[$i]) or die("Err program") ;
echo $sql[$i];
ลอง echo $sql[$i]; ดูน่ะครับ ว่าค่าที่เราส่งไปมันถูกต้องหรือไม่
Date :
2010-07-18 08:28:55
By :
webmaster
มันส่งเข้าฐานข้อมูล...ว่างเปล่าหมดเลยครับ
update member set name='' where member_id='#0001'
update member set lastname='' where member_id='#0001'
update member set organization='' where member_id='#0001'
update member set address='' where member_id='#0001'
update member set address2='' where member_id='#0001'
update member set district='' where member_id='#0001'
update member set province='' where member_id='#0001'
update member set zipcode='' where member_id='#0001'
update member set phone='' where member_id='#0001'
Date :
2010-07-18 09:23:19
By :
aofza704
มันไม่ลงหรอกครับ
<input name="name2" type="text" size="30" value="<?php echo "$dbarr[name]" ; ?>">
ชื่อมันเพี้ยนไปหมด
แล้วก็ไม่ต้องใช้ update ทีละฟิวด์หรอกครับใช้
update tablename set field1 = 'a', field2 = 'b', ... where เอาครับ
Date :
2010-07-18 13:05:10
By :
PlaKriM
แก้ได้แล้วครับ ขอบคุณครับ
Date :
2010-07-18 13:39:55
By :
aofza704
Load balance : Server 01