Registration workflow

So far whenever the user submitted a registration form filtering checks were made(sanitization/validation) and if these tests were passed, a registration function was called and int it another check was made if the submitted username/e-mail was the same with that in the database.

Do you think the above workflow is OK?

Is it maybe better that the check for the username/e-mail (if a similar exists in the database) is made together with the other checks and BEFORE the registration function gets called? The registration function just opens a connection to the database and enters the form data in it.

I am not saying the above scheme is incorrect, but I just want to hear views about it.

WE are always talking here about server-side validations/work.