Does it make any sense to validate a received parameter which will be used for example only as a comparator?
Let's say I received an email address from the user and I want to check whether it exists in the database.
I could firstly check if it is really an email address and then try to find it in the database. E.g:
$email = trim($_POST["email"]);
if (isEmail($email)) {
if (isRegisteredEmail($email)) { // Will execute a SQL query
echo "Email address registered";
}
else {
echo "Email address is not registered";
}
}
else {
echo "This is not an email address";
}
Or I could just simply do something like this:
if (isRegisteredEmail(trim($_POST["email"])) { // Will execute a SQL query
echo "Email address registered";
}
else {
echo "Email address is not registered";
}
I believe this is probably more an UX problem but...