ユーザーがユーザーを削除および更新できるユーザー管理ページがあります。ユーザーの削除ページと更新ページを、ウィンドウを閉じるオプションを備えたポップアップウィンドウにしたいと思います。しかし、方法がわかりません。ここに私の管理ユーザーコードがあります
<?php
//MY PHP stuff
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8” />
<title>Manage Users</title>
<link rel="stylesheet" type="text/css" href="../allcss/style.css" />
</head>
<body>
<?php
require('../Login/includes/header.inc.php');
?>
<div id="personalised">
<p>Hello, </p>
</div>
<div id="content">
<table>
<tr>
<th scope="col">User email</th>
<th scope="col">User name</th>
<th scope="col">User role</th>
<th> </th>
<th> </th>
</tr>
<?php while($row = $result ->fetch_assoc()) { ?>
<tr>
<td><?php echo $row['user_email']; ?></td>
<td><?php echo $row['user_name']; ?></td>
<td><?php echo $row['user_role']; ?></td>
<td><a href="update_users.php?person_id=<?php echo $row['person_id']; ?>">EDIT</a></td>
<td><a href="delete_users.php?person_id=<?php echo $row['person_id']; ?>">DELETE</a></td>
</tr>
<?php } ?>
</table>
</div>
</body>
</html>
これが update_user.php ページです
<?php
require_once 'login.php';
$table="users";
$OK = false;
$done = false;
$conn = new mysqli ($host, $user, $password, $database) or die("Connection Failed");
$stmt= $conn->stmt_init();
if (isset($_GET['person_id']) && !$_POST) {
// prepare SQL query
$sql = 'SELECT person_id, user_email, user_name, user_role FROM users
WHERE person_id = ?';
if ($stmt->prepare($sql))
{
$stmt->bind_param('i', $_GET['person_id']);
$stmt->bind_result($person_id, $user_email, $user_name, $user_role);
$OK = $stmt->execute();
$stmt->fetch();
$_SESSION['uemail_update'] = $user_email; //new
}
}
if (isset($_POST ['update'])) {
// prepare update query
$sql = 'UPDATE users SET user_name = ?, user_role = ?
WHERE person_id = ?';
if ($stmt->prepare($sql)) {
$stmt->bind_param('ssi', $_POST['user_name'], $_POST['user_role'], $_POST['person_id']);
$done = $stmt->execute();
}
}
// redirect if $_GET['aperson_id'] not defined
if ($done) {
header('Location: update_users_confirm.php');
exit;
}
if (!isset($_GET['person_id'])) {
header("Location: manage_users.php");
exit;
}
// store error message if query fails
if (isset($stmt) && !$OK && !$done) {
$error = $stmt->error;
}
?>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8” />
<title>Project Confirmation</title>
<link rel="stylesheet" type="text/css" href="../allcss/style.css" />
</head>
<body>
<?php
require('../Login/includes/header.inc.php');
?>
<div id="personalised">
<p>Hello, </p>
</div>
<div id="content">
<?php
if (isset($error)) {
echo "<p class='warning'>Error: $error</p>";
}
if($person_id == 0) { ?>
<p class="warning">Invalid request: user does not exist.</p>
<?php } else { ?>
<form id="form1" method="post" action="">
<p>
<label for="user_name">User name:</label>
<input name="user_name" type="text" class="widebox" id="user_name" value="<?php echo htmlentities($user_name, ENT_COMPAT, 'utf-8'); ?>">
</p>
<p>
User role: <select name="user_role" size="1" id="user_role">
<option value="PT">Part timer</option>
<option value="FT">Full timer</option>
<?php echo htmlentities($user_role, ENT_COMPAT, 'utf-8'); ?></select>
</p>
<p>
<input type="submit" name="update" value="Update Entry" id="update">
<input name="person_id" type="hidden" value="<?php echo $person_id; ?>">
</p>
</form>
<?php } ?>
</div>
</body>
</html>
update_user.php ページがポップアップ ウィンドウに表示され、送信時に Confirmation.php ページも表示されるように助けてください。
ありがとう