Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 599961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:33:18+00:00 2026-05-13T16:33:18+00:00

Using Codeigniter, I’m able to create a function for user authentication. I have a

  • 0

Using Codeigniter, I’m able to create a function for user authentication.
I have a function that I call to check if the username/password given are valid.
The problem I’m having is, I don’t want the code to display “Invalid Login” if a password isn’t given. It should read “Password is required” or something like that.

I guess I could NOT require the password field, in that case a blank password would result in a failed log in anyways. However, I want to make sure sql injection doesn’t occur.

$this->form_validation->set_rules('username','username','required|callback_authenticate');
$this->form_validation->set_rules('password','password','required');

$this->form_validation->set_message('authenticate','Invalid login. Please try again.');

authenticate function

function authenticate() {

    return Current_User::checkLogin($this->input->post('username'),
                                          $this->input->post('password'));
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:33:19+00:00Added an answer on May 13, 2026 at 4:33 pm

    I suggest that you create a callback function that you can use as a rule that you can add to the set_rules() function like this:

    $this->form_validation->set_rules(‘password’,’Password’,’required|your_callback_function’);

    This way, the required rule is sure to be called first. When the user types in a password, then the next rule is checked. In this case, it goes through your callback validation function. If the user doesn’t enter anything in your password field, then the error message should automatically show that the password is required.

    If you want to prevent SQL injection on the password field, add the sha1 or md5 rule to the password field.

    Check out the Callbacks: Your own Validation Functions in the Form Validation library.

    Also, if you will use the Active Record class instead of manually typing in your query, your queries will be safer since values are automatically escaped by the system. You also have the option to use prepared statements to prevent SQL injection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 354k
  • Answers 354k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I suppose this should be updated now that the landscape… May 14, 2026 at 8:19 am
  • Editorial Team
    Editorial Team added an answer Yes, you should return immediately when the consumer is setting… May 14, 2026 at 8:19 am
  • Editorial Team
    Editorial Team added an answer You could use a symmetric encryption algorithm. Here's an example.… May 14, 2026 at 8:19 am

Related Questions

Using CodeIgniter's Active Record class and MySQL, I have a table of posts with
I am using Codeigniter framework and I have a form with input fields. When
I'm using CodeIgniter and I got a model that fetches let's say all recipes
I've been using CodeIgniter for some time, and I liked it a lot. It
I'm using CodeIgniter, and I'm not able to use my database with it. I'm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.