Update file users.php

This commit is contained in:
Jan BELLON 2024-03-12 15:06:30 +00:00
parent 6844b1fbbe
commit cd59839803

View File

@ -12,9 +12,9 @@ if(isset($_POST['userid']) && isset($_POST['role']) && isset($_POST['accreditati
$bdd = connect($dbhost, $dbname, $dbuser, $dbpass);
$req = $bdd->prepare("UPDATE users SET role = :role, accreditation = :accreditation WHERE ID = :userid");
$req->bindParam(':role',$_POST['role']);
$req->bindParam(':accreditation',$_POST['accreditation']);
$req->bindParam(':userid', $_POST['userid']);
$req->bindParam(':role',$_POST['role'], PDO::PARAM_INT);
$req->bindParam(':accreditation',$_POST['accreditation'], PDO::PARAM_INT);
$req->bindParam(':userid', $_POST['userid'], PDO::PARAM_INT);
if ($req->execute()) {
$status = "Utilisateur mis à jour";
} else {
@ -148,7 +148,7 @@ if(isset($_POST['userid']) && isset($_POST['role']) && isset($_POST['accreditati
echo "</select>";
echo "<select name='role' required>";
foreach($roles as $id => $nom) {
if($row['accreditation'] == $id) {
if($row['role'] == $id) {
echo '<option value="' . $id .'" selected>' . $nom . '</option>';
} else {
echo '<option value="' . $id .'">' . $nom . '</option>';