Have you started here in the Codex (always a good place to go): https://codex.wordpress.org/Customizing_the_Login_Form . Lots of help there (and in links therein) on how to customize the login form.
And, lots of tutorials found via the googles.
Your code is assuming a lot of things that aren’t true. Forms in WP are different than forms in PHP/HTML. The query to get login authentication is different than you are trying, if you are accessing the WP user table. And your query into your own database is also in error – your ‘and’ condition is not properly formatted.
Rather than providing all of the answers – and reinventing the wheel because of all the googles on this subject – I recommend you start with the Codex link above, and then look at all of the tutorials on this subject.
It’s not clear whey you would want to have a separate user table, either – what is it about the WP user table that doesn’t meet your needs? You can add user roles to the WP user table to customize access levels.
So, more (much more) detail is needed. This question is a bit broad in scope.