0
votes

How can I query SQL to display an error message? Suppose the user types in his username and password. When he types a wrong username, an "Error: Invalid Username" will appear. And when he types in a wrong password, an "Error: Invalid Password" will appear.

P.S. I'm a beginner in CodeIgniter and PHP.

1
read codeignitor documentation - Tamil Selvan C

1 Answers

0
votes

You can do it as below:

1) Get a single record from the users table you have using the user entered username.

2) If you got a result, then go to step 3 , else display a message, *Invalid username *.

3) If the use is found, then check compare the passwords. If passwords matches, then login user else display Invalid password error

For database operations, you can use CI active records which are good and easy to use. For CI database operations, please read this

http://ellislab.com/codeigniter/user-guide/database/index.html

Hope this will help.

Thank you