Create a stored procedure in the MySQL database (if you have a version which supports procedures) which has input parameters for the username and password. Pass it the username and password and within the procedure have it check a table and see if the username and password exist in a single row. Something like this.
CREATE PROCEDURE MyProcedure
WHERE UserName = @UserName
and Password = @Password
Then if there is no record it’s not a valid account. If there is a record it is a valid account.
This page has come good info about using stored procedures.