Looking for a way to change $$key to something like $$key_errorso the variable will look something like: $name_error outside the foreach loop.
Here is what I have so far:
foreach ($_POST as $key => $value) {
$$key = strip_tags(mysqli_real_escape_string($mysqli, $value));
if (empty($value)) {
// change variable below to something like $$key_error ($$name_error)
$$key = 'is-invalid';
} else {
$$key = "value='$value'";
}
}
When an input is empty the user will return to the registration form, the input that is empty will have red bootstrap borders. When a field is not empty, the value will still be there so they do not have to do it all over.
<input type="text" name="name" class="form-control form-control-lg <?=$name?>" style="text-align:center;" placeholder="Voor- en achternaam" <?=$name?>>
I hope it all makes sense :)
$errorsarray.$errors[$key] = <error relative to that key here>;