Undefined index $_POST

it looks like $row[‘matriculeAgent’] is not set. this could be caused by multiple causes. I noticed several problems in your code, which I try to explain here.

first of all, if you want to you prepared statements, dont include your parameters directly inside the stmt->prepare() function call, use bind-param instead:

$stmt = $bdd->prepare("SELECT `matriculeAgent`, `motdepasseAgent` FROM `utilisateurs` WHERE `matriculeAgent` = ? AND `motdepasseAgent` = ?");
$stmt->bind_param("ss", $matricule_verif, $motdepasse_verif);

then, another problem may be that you did not execute the statement, or you didn’t show it in the post.


after that, you can simply fetch your results, it should then be correctly populated:

$result = $stmt->get_result();

another way after execute(): as you are already using prepared statements, you could use here also bind_result(), which will populate your desired variables:

$varA = '';
$varB = '';
$stmt->bind_result($varA, $varB);

Browse More Popular Posts

Leave a Comment