Hi @shahzadyounas ,
This problem seems to me like an architectural problem more than a code logic problem.
I will be just suggesting you a different way which you can implement in the application.
Currently, you have three different kinds of Users: Admin, Teachers, and Students in three different tables. But, I will suggest you have a single table 'Users'. In that users table, you can have an attribute as 'type' which defines a User type which could be: Admin, Student or Teacher. And Make the 'Email' as Unique. It will solve your mentioned both problems in an easy way. While logging in, just check the credentials in 'Users' table, if credentials are verified then check the User->type using 'if statement' and return the relevant view according to the User type.
Why I am focusing on architecture because if you will go with your architecture, it will be too much pressure on the application while querying three kinds of tables just to log in a User. With the new approach, it is easy to implement, and not too much hectic for the development and the application performance.
Just think about the application performance also while development.
Thanks.