|
![](/images/resource/spacer.gif) |
|
php code ทำไมมันไม่ยอม update ข้อมูล ใน sql ให้อ่ะ |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
staff_edit.php
<?php require_once("includes/function.php");
if(!isset($_SESSION['ssAdmin'])){
header("location:admin_login.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>แก้ไขข้อมูลพนักงาน</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body>
<div>
<center><table align="center" width="100%">
<tr><td bgcolor="yellow" align="center" height="20" style="font-weight:bold; font-size:16px; color:#FF0000">*คำเตือน! อย่าลืมออกจากระบบทุกครั้งหลังจากเสร็จการทำงาน</td></tr></table></center>
</div>
<div id="wrapper">
<div id="header">
<div id="logo">
<h1><a href="index.php">Football Ticket System</a></h1>
<p><a href="index.php">ระบบจองตั๋วในสนามฟุตบอล!</a></p>
</div>
<div id="menu">
<ul>
<li><a href="index.php">หน้าแรก</a></li>
<li><a href="infopay.php">การชำระและรับตั๋วฟุตบอล</a></li>
<li><a href="contactus.php">ติดต่อเรา</a></li>
<li><a href="about.php">เกี่ยวกับเรา</a></li>
<li class="active"><a href="alogout.php">ออกจากระบบผู้ดูแลระบบ</a></li>
</ul>
</div>
<!-- end #menu -->
</div>
<!-- end #header -->
<div id="page">
<div id="header-pic"></div>
<div id="content">
<div class="post">
<h1 class="title"><a>Edit/Update Staff</a></h1>
<p class="byline"><small>แก้ไขข้อมูลพนักงาน</small></p>
<div class="entry">
<p>
<?php
$dblink = connect_db( ) ;
$auser = $_GET["username"] ;
$sql = " SELECT * FROM ftsadmin WHERE aUsername = '$auser'" ;
$resultSql = mysqli_query( $dblink, $sql ) ;
$row = mysqli_fetch_assoc( $resultSql ) ; ?>
<form action="staff_editProcess.php" method="post">
<table border="0" width="100%" style="font-weight:bold; color:#666666">
<tr height="30" bgcolor="#FFDA6B">
<td colspan="2" align="center" style="color:#0000FF">แก้ไขข้อมูลสำหรับพนักงาน</td>
</tr>
<tr bgcolor="#FFFFCC" align="left">
<td>ชื่อผู้ใช้</td>
<td style="color:red"><input name="txtUser" type="text" maxlength="20" value="<?php echo $row["aUsername"] ; ?>" ><small> ภาษาอังกฤษ และตัวเลขเท่านั้น (5-20 ตัวอักษร)</small> </td>
</tr>
<tr bgcolor="#FFFFCC" align="left">
<td>อีเมล์ </td>
<td style="color:red"><input name="txtEmail" type="text" size="30" value="<?php echo $row["aEmail"] ; ?>" ><small> ตัวอย่าง [email protected]</small></td>
</tr>
<?php if ($_SESSION['ssAdmin'] == $row["aUsername"]) {?>
<tr bgcolor="#FFFFCC" align="left">
<td style="color:red">(*)รหัสผ่านเดิม</td>
<td style="color:red"><input type="password" name="txtOldPwd" maxlength="20"><small> ต้องระบุให้ตรงกับรหัสผ่านเดิม (ทุกครั้ง)</small></td>
</tr>
<tr height="30" bgcolor="#FFDA6B">
<td colspan="2" align="center" style="color:#0000FF">สำหรับต้องการเปลี่ยนรหัสผ่าน ถ้าไม่เว้นว่างไว้</td>
</tr>
<tr bgcolor="#FFFFCC" align="left">
<td>รหัสผ่านใหม่</td>
<td style="color:red"><input name="txtNewPwd" type="password" maxlength="20"><small> ภาษาอังกฤษ ตัวเลข และเครื่องหมาย _ เท่านั้น (5-20 ตัวอักษร)</small> </td>
</tr>
<tr bgcolor="#FFFFCC" align="left">
<td>ยืนยันรหัสผ่านใหม่</td>
<td style="color:red"><input name="txtConfirmNewPwd" type="password" maxlength="20"><small> ต้องระบุให้ตรงกับรหัสผ่านใหม่</small></td>
</tr>
<tr bgcolor="#FFFFCC" align="left">
<td colspan="2" style="color:red"><small><br/>*หมายเหตุ*<br/>-(*)การแก้ไขข้อมูลของชื่อบัญชีของตนเองต้องระบุรหัสผ่านเดิมทุกครั้ง เพื่อเป็นการตรวจสอบ<br/>- ถ้าท่านไม่ต้องการเปลี่ยนรหัสผ่านใหม่ กรุณากรอกรหัสผ่านเดิมแล้วเว้นว่างที่ช่องรหัสผ่านใหม่และช่องยืนยันรหัสผ่านใหม่ </small></td>
</tr>
<?php } ?>
<tr height="30" bgcolor="#FFDA6B">
<td colspan="2" align="center" style="color:#0000FF">แก้ไขข้อมูลส่วนตัว</td>
</tr>
<tr bgcolor="#FFFFCC" align="left">
<td>ชื่อ</td>
<td><input name="txtName" type="text" value="<?php echo $row["aName"] ; ?>" ></td>
</tr>
<tr bgcolor="#FFFFCC" align="left">
<td>นามสกุล</td>
<td><input name="txtSurname" type="text" value="<?php echo $row["aLastname"] ; ?>" ></td>
</tr>
<tr bgcolor="#FFFFCC" align="left">
<td>โทรศัพท์</td>
<td style="color:red"><input name="txtPhone" type="text" maxlength="10" value="<?php echo $row["aPhone"] ; ?>" ><small> ตัวเลขเท่านั้น เช่น 0812345678</small></td>
</tr>
<tr bgcolor="#FFFFCC" align="left">
<? if ($_SESSION['ssAdminGroup'] == 'A') {?>
<td>Group</td>
<td style="color:red"><?php $arr_group = array("A", "S") ;
echo "<select name=\"selGroup\" id=\"select\">" ;
for( $i=0; $i<count($arr_group); $i++ ) {
echo "<option value=\"" . $arr_group[$i] . "\"" ;
if ( $arr_group[$i] == $row["aGroup"] ) {
echo "selected=\"selected\"" ;
}
echo " >" . $arr_group[$i] . "</option>" ;
}
echo "</select>" ; ?><br/><small> A=Administrator(ผู้ดูแลระบบ) มีสิทธิ์ทุกอย่างในระบบ<br/>S = Staff (เจ้าหน้าที่) มีสิทธิ์เหมือนกับ A แต่ไม่สามารถลบหรือแก้ไขข้อมูลในกลุ่ม A ได้</small></td>
<? } else { ?>
<td>Group</td>
<td style="color:red"><input name="selGroup" type="hidden" value="S" >คุณมีสิทธิ์เพิ่มกลุ่มแบบ S(Staff) เท่านั้น</td>
<? } ?>
</tr>
<tr bgcolor="#FFFFCC"><td colspan="2" align="center">
<br/><br/>
<input type="submit" value="เปลี่ยนแปลงข้อมูล" name="btnOK"/>
<input type="button" onclick="location.href='staff_manage.php'" value="ยกเลิก" name="btnCancel">
<input name="uid" type="hidden" value="<?php echo $row["aUsername"] ; ?>">
</td></tr>
</table>
</form>
</p>
</div>
</div>
</div>
<!-- end #content -->
<div id="sidebar">
<div id="sidebar-bgtop"></div>
<div id="sidebar-content">
<div id="sidebar-bgbtm">
<ul>
<li>
<h2>Administrator Management</h2>
<?php if ($_SESSION["ssAdminGroup"] == 'A') { ?>
<center><h5><?php echo 'ยินดีต้อนรับคุณ ' .$_SESSION["ssAdmin"]. ' ได้รับสิทธิ์ในฐานะผู้ดูแลระบบ<br/>กรุณาเลือกเมนูที่ต้องการด้านล่างนี้'; ?></h5></center>
<? } else { ?>
<center><h5><?php echo 'ยินดีต้อนรับคุณ ' .$_SESSION["ssAdmin"]. ' ได้รับสิทธิ์ในฐานะเจ้าหน้าที่<br/>กรุณาเลือกเมนูที่ต้องการด้านล่างนี้'; ?></h5></center>
<? } ?>
<ul>
<li><a href="admin.php">หน้าแรกของระบบจัดการ</a></li>
<li><a href="fticket_manage.php">ระบบการจองตั๋วฟุตบอล</a></li>
<li><a href="member_manage.php">การจัดการสมาชิก</a></li>
<li><a href="staff_manage.php">การจัดการเจ้าหน้าที่ในเว็บ</a></li>
<li><a href="football_manage.php">การจัดการข้อมูลการแข่งขัน</a></li>
<li><a href="summaryticket.php">สรุปรายละเอียดการจำหน่ายตั๋ว</a></li>
<li><a href="alogout.php">ออกจากระบบ</a></li>
</ul>
<h2>Main Menu</h2>
<ul>
<li><a href="index.php">หน้าแรก</a></li>
<li><a href="registmember.php">ลงทะเบียนสมาชิกใหม่</a></li>
<li><a href="infopay.php">การชำระเงินและรับตั๋วฟุตบอล</a></li>
<li><a href="contactus.php">ติดต่อเรา</a></li>
<li><a href="about.php">เกี่ยวกับเรา</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<!-- end #sidebar -->
<div style="clear:both; margin:0;"></div>
</div>
<!-- end #page -->
</div>
<div id="footer">
<p>
<? footer() ?>
</p>
</div>
<!-- end #footer -->
</body>
</html>
staff_editProcess.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>Staff Update Profile...</title>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
</head>
<body>
<br/><br/><br/>
<?php
require_once("includes/function.php");
$id = $_POST["uid"] ;
$URL_BACK = "staff_manage.php";
$URL_GOTO = "staff_manage.php";
if (!isset($_SESSION['ssAdmin'])){
$msg = "ไม่สามารถทำรายการได้ เนื่องจากคุณไม่ได้รับสิทธิ์การเข้าถึง" ;
process_message( $msg, "index.php" ) ;
}
if ($_SESSION['ssAdmin'] == $row["aUsername"]) {
if ( empty($_POST["txtUser"]) || empty($_POST["txtOldPwd"]) || empty($_POST["txtEmail"]) ) {
process_message( "ต้องกรอก \"ข้อมูลสำหรับเข้าระบบ\" ให้ครบ", $URL_BACK ) ;
} elseif ( strcmp($_POST["txtNewPwd"], $_POST["txtUser"]) == 0 ) {
process_message( "รหัสผ่าน ต้องไม่เหมือนกับ ชื่อผู้ใช้", $URL_BACK ) ;
} elseif ( valid_pwd($_POST["txtOldPwd"]) === false) {
process_message( "รหัสผ่านไม่ถูกต้องตามเงื่อนไขที่กำหนด", $URL_BACK ) ;
} elseif ( strcmp($_POST["txtNewPwd"], $_POST["txtConfirmNewPwd"]) != 0 ) {
process_message( "กรอกรหัสผ่านใหม่ และยืนยันรหัสผ่านใหม่ไม่ตรงกัน", $URL_BACK ) ;
} elseif ( strcmp( $_POST["txtOldPwd"], $_POST["txtNewPwd"] ) == 0 ) {
process_message( "กรุณาตั้งรหัสผ่านใหม่ ให้แตกต่างจากรหัสผ่านเดิม", URL_BACK ) ;
}
} elseif (empty($_POST["txtUser"]) || empty($_POST["txtEmail"])) {
process_message( "ต้องกรอก \"ข้อมูลสำหรับเข้าระบบ\" ให้ครบ", $URL_BACK ) ;
} elseif ( valid_user($_POST["txtUser"]) === false) {
process_message( "ชื่อผู้ใช้ไม่ถูกต้องตามเงื่อนไขที่กำหนด", $URL_BACK ) ;
} elseif ( valid_email( $_POST["txtEmail"] ) === false ) {
process_message( "อีเมล์ไม่ถูกต้อง", $URL_BACK ) ;
} elseif ( valid_numonly( $_POST["txtPhone"] ) === false) {
process_message( "เบอร์โทรศัพท์ กรุณาระบุเฉพาะตัวเลขเท่านั้น", $URL_BACK ) ;
} else if ($_SESSION['ssAdminGroup'] == 'S' and $row["aGroup"] == 'A') {
process_message( "ไม่สามารถแก้ไขชื่อ $auser นี้ได้<br/> เนื่องจากคุณคือ Staff Group ไม่มีสิทธิ์แก้ไขชื่อใน Admin Group ได้", "staff_manage.php" ) ;
} else if ($_SESSION['ssAdmin'] == $row["aUsername"]) {
$aPwd = trim( $_POST["txtOldPwd"] ) ;
$auser = $_GET["username"] ;
$dblink = connect_db() ;
$sql = " SELECT aUsername FROM ftsadmin WHERE aUsername = '$auser' AND aPassword = PASSWORD('$aPwd')" ;
@$resultSql = mysqli_query( $dblink, $sql ) ;
@$rows = mysqli_num_rows($resultSql) ;
if ( $rows == 1 ) {
if ( $_POST["txtNewPwd"] == "" ) {
$dblink = connect_db() ;
$upStaff = "UPDATE ftsadmin SET aUsername='".$_POST["txtUser"]."', aEmail='".$_POST["txtEmail"]."', aName='".$_POST["txtName"]."', aLastname='".$_POST["txtSurname"]."', aPhone='".$_POST["txtPhone"]."', aGroup='".$_POST["selGroup"]."' WHERE aUsername='$id'" ;
$reStaff = mysqli_query( $dblink, $upStaff ) ;
$affStaff = mysqli_affected_rows($dblink) ;
if ( $affStaff > 0 ) {
$msg = "บันทึกการแก้ไขเรียบร้อยแล้ว" ;
process_message( $msg, $URL_GOTO ) ;
} else {
$msg = "เกิดข้อผิดพลาด ไม่สามารถบันทึกการแก้ไขได้" ;
process_message( $msg, $URL_BACK ) ;
}
} else {
if ( valid_pwd($_POST["txtNewPwd"]) === false) {
process_message( "รหัสผ่านไม่ถูกต้องตามเงื่อนไขที่กำหนด", $URL_BACK ) ;
exit;
}
$dblink = connect_db() ;
$upStaff = "UPDATE ftsadmin SET aUsername='".$_POST["txtUser"]."', aPassword='".$_POST["txtNewPwd"]."', aEmail='".$_POST["txtEmail"]."', aName='".$_POST["txtName"]."', aLastname='".$_POST["txtSurname"]."', aPhone='".$_POST["txtPhone"]."', aGroup='".$_POST["selGroup"]."' WHERE aUsername='$id'" ;
$reStaff = mysqli_query( $dblink, $upStaff ) ;
$affStaff = mysqli_affected_rows($dblink) ;
if ( $affStaff > 0 ) {
unset($_SESSION["ssAdmin"]);
unset($_SESSION["ssAdminGroup"]);
session_destroy();
$msg = "บันทึกการแก้ไขเรียบร้อยแล้ว กำลังทำการออกจากระบบ<br/>กรุณาเข้าสู่ระบบใหม่อีกครั้ง" ;
process_message( $msg, "admin_login.php" ) ;
} else {
$msg = "เกิดข้อผิดพลาด ไม่สามารถบันทึกการแก้ไขได้" ;
process_message( $msg, $URL_BACK ) ;
}
}
}else{
$msg = "รหัสผ่านเดิมไม่ถูกต้อง <br/>หรือคุณไม่ได้รับอนุญาตให้เข้าใช้งาน" ;
process_message( $msg, $URL_BACK ) ;
}
}else{
$dblink = connect_db() ;
$upStaff = "UPDATE ftsadmin SET aUsername='".$_POST["txtUser"]."', aEmail='".$_POST["txtEmail"]."', aName='".$_POST["txtName"]."', aLastname='".$_POST["txtSurname"]."', aPhone='".$_POST["txtPhone"]."', aGroup='".$_POST["selGroup"]."' WHERE aUsername='$id'" ;
mysqli_query( $dblink, $upStaff1 ) ;
$affStaff = mysqli_affected_rows($dblink) ;
if ( $affStaff1 > 0 ) {
$msg = "บันทึกการแก้ไขเรียบร้อยแล้ว<br/>จำนวนแถวที่แก้ไข $affStaff" ;
process_message( $msg, $URL_GOTO ) ;
} else {
$msg = "เกิดข้อผิดพลาด ไม่สามารถบันทึกการแก้ไขได้" ;
process_message( $msg, $URL_BACK ) ;
}
}?>
</body>
</html>
ช่วยดูให้หน่อยครับ ทำตั้งนานแล้วไม่ได้เลยอ่ะ
ขอบคุณมาก ๆ ครับ
Tag : - - - -
![](/images/adv.jpg?v=1001)
|
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2009-12-08 00:02:17 |
By :
cskaza |
View :
2367 |
Reply :
3 |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
เพิ่ม hidden field ชื่อ ไอดี เข้าไป และ ใน file process.php เปลี่ยนจาก where ausername เป็น
where aid=$id แทน น่าจะดีกว่า
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2009-12-08 00:28:54 |
By :
yomaster |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ผมลองแล้วอ่ะ ก็ยังไม่ได้เลย
คือผมกำลังทำโปรเจคอ่ะ แล้วเพิ่งหัดศึกษา PHP อ่ะ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2009-12-08 12:58:25 |
By :
cskaza |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
ได้แล้วครับ
ผมใช้ $upStaff เป็น array ครับ แล้วใช้
loop for รันคำสั่งเพื่อให้เกิดการอัพเดทข้อมูลทีละคำสั่งครับ
Code (PHP)
$upStaff[0] = "UPDATE ftsadmin SET aUsername='".$_POST["txtUser"]."' WHERE aUsername='$id'";
$ipStaff[1] = "UPDATE ftsadmin SET aPassword='".$_POST["txtPassword"]."' WHERE aUsername='$id'";
for ($i=1;$i<count($upStaff);$i++) {
$reStaff = mysqli_query( $dblink, $upStaff ) ;
}
if ($reStaff) {
$msg = "บันทึกการแก้ไขเรียบร้อยแล้ว" ;
process_message( $msg, $URL_GOTO ) ;
} else {
$msg = "เกิดข้อผิดพลาด ไม่สามารถบันทึกการแก้ไขได้" ;
process_message( $msg, $URL_BACK ) ;
}
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2009-12-08 17:38:10 |
By :
cskaza |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 01
|