Edytuje mi każdy rekord oprócz id, a powinno edytować rekordy w danym idku
<?php
include('database.php');
if (isset($_GET['id'])) {
$idget = $_GET['id'];
if ($idget > 0) {
$id = $_GET['id'];
$sth = $pdo->prepare('SELECT * FROM users WHERE id = :id');
$sth->bindParam(':id', $id);
$sth->execute();
$result = $sth->fetch();
$idform = $result['id'];
$nameform = $result['name'];
$emailform = $result['email'];
$passwordfrom = $result['password'];
}
}
if (isset($_POST['change'])) {
$sth = $pdo->prepare('UPDATE `users` SET `name`=:n,`email`=:e,`password`=:p WHERE :i');
$sth->bindParam(':i', $idform);
$sth->bindParam(':n', $_POST['name']);
$sth->bindParam(':e', $_POST['email']);
$sth->bindParam(':p', $_POST['password']);
$sth->execute();
header('Location: index.php');
}
?>
<form action="edit.php" method="post">
<h1><?php echo $idform; ?></h1>
<input type="text" name="name" value="<?php echo $nameform ?>">
<input type="text" name="email" value="<?php echo $emailform ?>">
<input type="text" name="password" value="<?php echo $passwordfrom ?>">
<input type="text" name="password" value="<?php echo $passwordfrom ?>">
<input type="hidden" name="change" value="change" >
<input type="submit">
</form>