|
|
|
ส่งค่า id จากฟอร์มมาได้แล้วแต่ update ข้อมูลไม่ได้คับช่วยหน่อยนะคับไม่รู้ผิดตรงไหน |
|
|
|
|
|
|
|
ID ส่งค่ามาแล้วคับแต่ไม่รู้ตรงอัพเดทผมเขียนถูกไหมรบกวนช่วยหน่อยคับ
Code (PHP)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>SYSTEM ADMIN</title>
<form action="action_edit.php" method="POST" name="edit" id="edit " role="form">
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="m_username" class="control-label">Username :</label>
<input type="text" class="form-control" id="m_username" name="m_username" value="5555" autocomplete="off">
</div></div>
<div class="col-lg-6">
<div class="form-group">
<label for="m_password" class="control-label">Password :</label>
<input type="text" class="form-control" id="m_password" name="m_password" value="5555" autocomplete="off">
</div></div></div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="m_name" class="control-label">Name :</label>
<input type="text" class="form-control" id="m_name" name="m_name" value="5555" autocomplete="off">
</div></div>
<div class="col-lg-6">
<div class="form-group">
<label for="m-nick" class="control-label">Nick Name :</label>
<input type="text" class="form-control" id="m_nick" name="m_nick" value="5555" autocomplete="off">
</div></div></div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="m_tel" class="control-label">Tel :</label>
<input type="text" class="form-control" id="m_tel" name="m_tel" value="5555" autocomplete="off">
</div></div>
<div class="col-lg-6">
<div class="form-group">
<label for="m_email" class="control-label">Email :</label>
<input type="text" class="form-control" id="m_email" name="m_email" value="5555" autocomplete="off">
</div></div></div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="m_department" class="control-label">Department :</label>
<select type="text" class="form-control" id="m_department" name="m_department" autocomplete="off">
<option value="5555" >5555</option>
<option>CEO</option>
<option>CI</option>
<option>ACC</option>
<option>HR</option>
<option>IT</option>
<option>QMR</option>
<option>DCC</option>
<option>SHE</option>
<option>PU</option>
<option>MS</option>
<option>R&D</option>
<option>PR</option>
<option>TF</option>
<option>QC</option>
<option>ST</option>
<option>EN</option>
<option>PPC</option>
</select>
</div></div>
<div class="col-lg-6">
<div class="form-group">
<label for="m_startwork" class="control-label">Startwork :</label>
<input type="text" class="form-control" id="m_startwork" name="m_startwork" value="5555" autocomplete="off">
</div></div></div>
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<label for="m_level" class="control-label">Level :</label>
<select class="form-control" id="m_level" name="m_level" >
<option value="5555">5555</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div></div></div>
<div class="form-group">
<button type="submit" class="btn btn-success" id="btn"><i class="fa fa-save"></i> บันทึก</button>
<a href="tables_user_board.php" class="btn btn-warning" id="btn"> ยกเลิก </a>
<input type="hidden" name="m_id" id="m_id" value="<?php echo $row_showuser['m_id']; ?>">
</div>
</form>
</body>
</html>
Code (PHP)
<meta charset="UTF-8" />
<?php
/**/
echo "<pre>";
print_r($_POST);
echo "</pre>";
exit();
//*** Update Record ***//
$hostname_condb = "localhost";
$database_condb = "mydatabase";
$username_condb = "root";
$password_condb = "";
$condb = mysql_pconnect($hostname_condb, $username_condb, $password_condb) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_query("SET NAMES UTF8");
$m_id = $_GET['m_id'];
$m_username = $_POST['m_username'];
$m_password = $_POST['m_password'];
$m_name = $_POST['m_name'];
$m_nick = $_POST['m_nick'];
$m_tel = $_POST['m_tel'];
$m_email = $_POST['m_email'];
$m_department = $_POST['m_department'];
$m_startwork = $_POST['m_startwork'];
$m_level = $_POST['m_level'];
$sql = "UPDATE tb_member SET m_username='$m_username', m_password='$m_password',
m_name='$m_name', m_nick='$m_nick', m_tel='$m_tel', m_email='$m_email',
m_department='$m_department', m_startwork='$m_startwork', m_level='$m_level' WHERE m_id='m_id'";
$row = mysql_query($sql);
//echo $sql;
//exit();
//$row = mysql_query($sql);
if($row)
{
echo "<script type='text/javascript'>";
echo "alert('แก้ไขข้อมูลเรียบร้อย');";
echo "window.location='tables_user_board.php';";
echo "</script>";
}
else
{
echo "<script type='text/javascript'>";
echo "alert(".$sql.");";
echo "window.location='form_edit_user_board.php?m_id=m_id';";
echo "</script>";
}
?>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2018-08-24 10:21:00 |
By :
HLEW |
View :
1733 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4-8 เอาออกครับ
------------
Check
-------------
คืออะไร m_id ?
ได้มาจากไหน ? ถ้า ส่งมาแบบ get $_GET['m_id '];
------------
จะ Update ก็ต้อง ส่งค่าที่จะ Update ไป Update แล้ว
แต่ที่นี้ ผิดที่ WHERE m_id='m_id' ไม่มันรู้จัก m_id
|
|
|
|
|
Date :
2018-08-24 10:51:03 |
By :
Hararock |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตรง where ตก $ ไปนะครับ
|
|
|
|
|
Date :
2018-08-29 22:30:27 |
By :
Jatmentz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|