I'm trying to make a registration form with PHP and I was wondering if it was possible if I could find out which variable does not meet the condition in this example;
if (ctype_alpha($firstname, $lastname, $country)) {
// in this situation the given variables meet the condition
}
else {
echo "The variable" . (variable) . "should only contain letters"
}
I know I could just make 3 if-statements in this situation and echo the error under every else statement, but if I have a form with lots of fields the code would be getting so messy because of all those if-statements in my opinion. I'm pretty new to PHP so I was just wondering if there's simple a way of doing this. Would be really useful!
Aucun commentaire:
Enregistrer un commentaire