This is the code:
$stmt = $db->prepare("SELECT DISTINCT * FROM kurssit WHERE BINARY id=? AND BINARY avain=?");
$stmt->bind_param("is", $kurssi, $avain);
// prepare and bind
$kurssi = $_POST["kurssi"];
$avain = $_POST["username"];
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows == 0) {
echo json_encode(array('status' => 'error'));
} else {
$_SESSION[KurssiId] = $kurssi;
echo json_encode(array('status' => 'success'));
}
Why can I not sql inject this? I tried doing kurssi=0'or 1=1-- -
, but it doesnt work for some reason? What am i missing here? Even sqlmap doesnt find an injection for some reason
kurssi=0'or 1=1-- -
should return all rows, which means that the if
statement is false