I know perfectly well that preventing tampering with a form is impossible.
But I want to ask, by implementing this function that generates a random number in a page hosting a form and echoing it in a hidden input field
function makeRandomString($bits = 256) {
$bytes = ceil($bits / 8);
$return = '';
for ($i = 0; $i < $bytes; $i++) {
$return .= chr(mt_rand(0, 255));
}
return $return;
}
if at the time of submitting, I checked with a query if that code already exists in the table of random_codes created before, if it exists, it blocks everything, and if it does not exist, it inserts it and executes the query.
Could that be a good thing?