I'm trying to update a few users after I entered into their profile.
This is the button to transfer me to their profile page. Everything works fine until I try to update some info.
echo "<td>" .'<a href="profile.php?id=' . $row['id']. '"><button class="view">View Profile</button></a>'. "</td>";
This is the profile page:
$id = $_GET['id'];
$db = mysqli_connect('localhost', '###', '###', '###');
$sql = "SELECT * FROM clients WHERE id='".$id."' ";
$result = mysqli_query($db, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
echo "<table>
<tr>
<th> Naam </th>
<th> id </th>
<th> email </th>
</tr>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
$name = $row['name'];
$email = $row['email'];
}
}
if (isset($_POST['pinfo'])) {
$query = "UPDATE clients SET name=? , email=?
WHERE id=?";
$stmt = mysqli_prepare($db, $query);
mysqli_stmt_bind_param($stmt, 'sss', $_POST['name'], $_POST['email'], $id);
mysqli_stmt_execute($stmt);
}
After trying to update I just get an error of "Undefined index: id"