|
|
|
ปรึกษา หน้า form-edit.php และ หน้า edit.php ในส่วนของ pages manager |
|
|
|
|
|
|
|
Quote:code ทั้งหมดครับ
Code (index.php)
<?php
require_once('../../../database/connection.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>ผู้ดูแลระบบ | CMS</title>
<link rel="shortcut icon" type="image/x-icon" href="../../../assets/images/logo.png">
<!-- stylesheet -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Kanit" >
<link rel="stylesheet" href="../../../plugins/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="../../../plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
<link rel="stylesheet" href="../../../assets/css/adminlte.min.css">
<link rel="stylesheet" href="../../../assets/css/style.css">
<!-- Datatables -->
<link rel="stylesheet" href="../../../plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="../../../plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
<?php include_once('../includes/sidebar.php') ?>
<div class="content-wrapper pt-3">
<!-- Main content -->
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card shadow">
<div class="card-header border-0 pt-4">
<h4>
<i class="fas fa-user-cog"></i>
ผู้ดูแลระบบ
</h4>
<a href="form-create.php" class="btn btn-primary mt-3">
<i class="fas fa-plus"></i>
เพิ่มข้อมูล
</a>
</div>
<div class="card-body">
<!-- <div style="overflow-x:auto;"> -->
<div class="table-responsive">
<table id="dataTables" class="table table-striped table-hover " >
<thead class="">
<tr>
<th>ลำดับ</th>
<th>ชื่อจริง</th>
<th>นามสกุล</th>
<th>อีเมล</th>
<th>ชื่อผู้ใช้งาน</th>
<th>สิทธิ์เข้าใช้งาน</th>
<th>วันที่สร้าง</th>
<th>วันที่แก้ไข</th>
<th>จัดการ</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT * FROM user";
$result = $conn->query($sql);
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
?>
<tr>
<td class="text-left"><?php echo $row["id"]; ?></td>
<td class="text-left"><?php echo $row["firstname"]; ?></td>
<td class="text-left"><?php echo $row["lastname"]; ?></td>
<td class="text-left"><?php echo $row["email"]; ?></td>
<td class="text-left"><?php echo $row["username"]; ?></td>
<td class="text-left"><?php echo $row["userlevel"]; ?></td>
<td class="text-left"><?php echo $row["created_at"]; ?></td>
<td class="text-left"><?php echo $row["updated_at"]; ?></td>
<td>
<div class="btn-group" role="group" aria-label="Basic mixed styles example">
<a href="form-edit.php?update_id=<?php echo $row["id"]; ?>" type="button" class="btn btn-danger"><i class="far fa-edit"></i>
</a>
<a href="delete.php?delete_id=<?php echo $row["id"]; ?>" type="button" class="btn btn-warning text-white"><i class="fas fa-trash"></i>
</a>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include_once('../includes/footer.php') ?>
</div>
<!-- scripts -->
<script src="../../../plugins/jquery/jquery.min.js"></script>
<script src="../../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="../../../plugins/sweetalert2/sweetalert2.min.js"></script>
<script src="../../../assets/js/adminlte.min.js"></script>
<!-- datatables -->
<!-- <script src="../../../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../../../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../../../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../../../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script> -->
</body>
</html>
Code (form-edit.php)
<?php
require_once('../../../database/connection.php');
require_once('edit.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>จัดการผู้ดูแลระบบ | AppzStory</title>
<link rel="shortcut icon" type="image/x-icon" href="../../../assets/images/logo.png">
<!-- stylesheet -->
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Kanit" >
<link rel="stylesheet" href="../../../plugins/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="../../../plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
<link rel="stylesheet" href="../../../assets/css/adminlte.min.css">
<link rel="stylesheet" href="../../../assets/css/style.css">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
<?php include_once('../includes/sidebar.php') ?>
<div class="content-wrapper pt-3">
<!-- Main content -->
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card shadow">
<div class="card-header border-0 pt-4">
<h4>
<i class="fas fa-user-cog"></i>
แก้ไขข้อมูลผู้ดูแลระบบ
</h4>
<a href="./" class="btn btn-info mt-3">
<i class="fas fa-list"></i>
กลับหน้าหลัก
</a>
</div>
<form action="edit.php" method="POST">
<div class="card-body">
<div class="row justify-content-center">
<div class="col-xl-6 px-1 px-md-5">
<div class="form-group">
<label for="firstname">ชื่อจริง</label>
<input type="text" class="form-control" name="txt_firstname" id="firstname" value="<?php echo $firstname; ?>" placeholder="ชื่อจริง" required>
</div>
<div class="form-group">
<label for="lastname">นามสกุล</label>
<input type="text" class="form-control" name="txt_lastname" id="lastname" value="<?php echo $lastname; ?>" placeholder="นามสกุล" required>
</div>
<div class="form-group">
<label for="email">อีเมลล์</label>
<input type="email" class="form-control" name="txt_email" id="email" value="<?php echo $email; ?>" placeholder="email" required>
</div>
<div class="form-group">
<label for="username">ชื่อผู้ใช้งาน</label>
<input type="text" class="form-control" name="txt_username" id="username" value="<?php echo $username; ?>" placeholder="ชื่อผู้ใช้งาน" disabled required>
</div>
</div>
<div class="col-md-6 px-1 px-md-5">
<div class="form-group">
<label for="password">รหัสผ่าน</label>
<input type="password" class="form-control" name="txt_password" id="password" value="<?php echo $password; ?>" placeholder="รหัสผ่าน" disabled required>
</div>
<div class="form-group">
<label for="userlevel">สิทธิ์การใช้งาน</label>
<select class="form-control" name="txt_userlevel" id="userlevel" value="<?php echo $userlevel; ?>" required>
<option value disabled selected>กำหนดสิทธิ์</option>
<option value="admin">Admin</option>
<option value="member">member</option>
</select>
</div>
</div>
</div>
</div>
<div class="card-footer">
<input type="hidden" name="update_id" value="<?php echo $_REQUEST['update_id']; ?>">
<button type="submit" name="btn_update" class="btn btn-primary btn-block mx-auto w-50" value="update">บันทึกข้อมูล</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include_once('../includes/footer.php') ?>
</div>
<!-- SCRIPTS -->
<script src="../../../plugins/jquery/jquery.min.js"></script>
<script src="../../../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="../../../plugins/sweetalert2/sweetalert2.min.js"></script>
<script src="../../../assets/js/adminlte.min.js"></script>
</body>
</html>
Code (edit.php)
<?php
require_once('../../../database/connection.php');
if (isset($_REQUEST['update_id'])) {
$sql = "SELECT * FROM `user` WHERE `id` = '".$_REQUEST['update_id']."' ";
$result= $conn->query($sql);
while ($row = $result->fetch_array(MYSQLI_ASSOC)) {
$firstname = $row["firstname"];
$lastname= $row["lastname"];
$email = $row["email"];
$username = $row["username"];
$password = $row["password"];
$userlevel = $row["userlevel"];
}
}
echo 'REQUEST:<pre>' . print_r($_REQUEST, true) . '</pre>';
echo 'GET:<pre>' . print_r($_GET, true) . '</pre>';
echo 'POST:<pre>' . print_r($_POST, true) . '</pre>';
if (isset($_REQUEST['btn_update'])) {
$firstname_up = $_REQUEST['txt_firstname'];
$lastname_up = $_REQUEST['txt_lastname'];
$email_up = $_REQUEST['txt_email'];
$username_up = $_REQUEST['txt_username'];
$password_up = $_REQUEST['txt_password'];
$userlevel_up = $_REQUEST['txt_userlevel'];
// echo $sqli = "UPDATE `masterpc` SET
$sqli = "UPDATE `user` SET
`firstname`='{$firstname_up}',
`lastname`='{$lastname_up}',
`email`='{$email_up}',
`username`='{$username_up}',
`password`='{$password_up}',
`userlevel`='{$userlevel_up}'
WHERE `id` = '".$_REQUEST['update_id']."' ";
if (mysqli_query($conn, $sqli)) {
echo "<script>alert('แก้ไขข้อมูลสำเร็จ...'); window.location:10 ='index.php';</script>";
} else {
echo "Error: " . $sqli . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
}
?>
|
|
|
|
|
Date :
2021-11-01 11:00:00 |
By :
TeeTs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ update ข้อมูลให้ครับ อยู่แต่หน้านี้ครับ
ภาพที่ 1
|
|
|
|
|
Date :
2021-11-01 20:57:23 |
By :
TeeTs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
no.4 แก้ได้แล้วครับ
ส่วนตรงนี้ปิดยังไงได้บ้างครับ .ใส่ hidden แล้ว ผมสงสัยว่าทำไม่หายครับ
|
|
|
|
|
Date :
2021-11-01 21:10:44 |
By :
TeeTs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update no.5 แก้ได้แล้วครับ
|
|
|
|
|
Date :
2021-11-01 21:14:54 |
By :
TeeTs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมก็บอกแล้วในคห. 2 รวมทั้งตัวที่ควรใช้แทนด้วย
ให้ลิ้งค์อ่านเพิ่มเติมด้วย
คุณอ่านหน่อยก็เข้าใจหมดแล้วเนี่ย
ให้ดูได้อย่างเดียวก็ readonly เพราะ disabled มันไม่ส่ง ผมก็บอกไปแล้ว แล้วมันเป็นมาตรฐานของมันอย่างนั้น จะใช้แล้วให้มันส่งข้อมูลด้วยก็ต้องเขียน web browser engine ขึ้นมาเองแล้วล่ะครับ
|
|
|
|
|
Date :
2021-11-01 22:08:33 |
By :
mr.v |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณครับ
|
|
|
|
|
Date :
2021-11-01 23:58:05 |
By :
TeeTs |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|