Actually malik is redirecting to "Good" or "Bad" based on the first user fetched, which is why the bad and inefficient method doesn't even do what it's supposed to do. (Only the first user in the table ever gets to log in.) But yes, just fixing that code isn't the thing to do. The query returning a simple yes or no is much better.
posted 9 years ago
Thanks for the reply.
I have corrected this problem by using this:
and it worked fine.
Now I want to know how to do it in an efficient manner, by using "mvc". So I don't have to write the code of connecting with the database again and again.
Moving this code to the model would be a good step.
Also, if you'd like to be more efficient and don't need the row data (if all you care about is whether the record exists or not) select count(*) will be more performant than select *. But if you need the data, select * is fine.