I have a problem, I want to make changes to a certain user’s database table. I managed to do this by opening another page.
<td><a href="includes/update.php?id=<? echo $user['id']?>" class="edit">Edit href</a></td>
The page will open as follows
page code img
But through the modal window, when I try to open the data, I get an error message: Warning: Undefined array key “id” in C:Program FilesAmppswwwadminindex.php on line 182
<td><button tupe="hidden" name="user_id" onclick="window.myDialog.showModal()" value="<? echo $user['id']?>" class="regbtn">Edit modal</button></td>
</tr>
<?
}
?>
</tbody>
</table>
<div class="left">
<dialog id="myDialog" class="modal">
<div class="reg-form">
<h6>Change the data</h6>
<button onclick="closeDialog()">x</button>
<script>
var x = document.getElementById("myDialog");
function showDialog() {
x.show();
}
function closeDialog() {
x.close();
}
</script>
<form method="POST">
<?
$id = $_GET['id'];
$query = mysqli_query($connect, query: "SELECT * from `users` where ID='$id'");
while($row = mysqli_fetch_array($query)) {
?>
<div class="reg-box">
<input type="text" value="<? echo $row["lastname"]?>" name="lastname" placeholder="Last Name">
</div>
<div class="reg-box">
<input type="text" value="<? echo $row["name"]?>" name="name" placeholder="Name">
</div>
<div class="reg-box">
<input type="text" value="<? echo $row["fathername"]?>" name="fathername" placeholder="Father Name">
</div>
<div class="reg-box">
<input type="number" value="<? echo $row["code"]?>" name="code" placeholder="Code">
</div>
<div class="reg-box">
<input type="text" value="<? echo $row["username"]?>" name="username" placeholder="Login">
</div>
<div class="reg-box">
<input type="number" value="<? echo $row["password"]?>" name="password" placeholder="Password">
</div>
<? } ?>
<button tupe="reg" class="btn">Edit</button>
</form>
</div>
<style type="text/css">
dialog {
margin-inline: auto;
margin-block-start: 120px;
background: transparent;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.211);
border: none;
border-radius: 1rem;
}
dialog::backdrop {
background-color: rgba(0, 0, 0, 0.2);
}
</style>
</dialog>
</div>
</div>