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

  • SEARCH
  • Home
  • 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 6908347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:33:07+00:00 2026-05-27T08:33:07+00:00

I have a form on my website header where i allow the user to

  • 0

I have a form on my website header where i allow the user to log in with his username/password… then i POST to /signin page and check if the username exists to allow the user to log in.. if there is a problem upon login i output these errors…

i tried using the following code to show a custom error but with no luck

    if ($this->form_validation->run() == false){
        $this->load->view("login/index", $data);
    }else{
        $return = $this->_submitLogin();
        if ($return == true){
            //success
        }else{
            $this->form_validation->set_message('new_error', 'error goes here');
            //error
        }
        $this->load->view("login/index", $data);
    }

how does set_message work and if this is the wrong method, which one allow me to show a custom error in this case?

EDIT :

validation rules:

private $validation_rules = array(
    array(
        'field'   => 'username',
        'label'   => 'Username',
        'rules'   => 'trim|required|callback__check_valid_username|min_length[6]|max_length[20]|xss_clean'
    ),
    array(
        'field'   => 'password',
        'label'   => 'Password',
        'rules'   => 'trim|required|min_length[6]|max_length[32]'
    ),
);
  • 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-27T08:33:07+00:00Added an answer on May 27, 2026 at 8:33 am

    The set_message method allows you to set your own error messages on the fly. But one thing you should notice is that the key name has to match the function name that it corresponds to.

    If you need to modify your custom rule, which is _check_valid_username, you can do so by perform set_message within this function:

    function _check_valid_username($str)
    {
       // Your validation code
       // ...
       // Put this in condition where you want to return FALSE
       $this->form_validation->set_message('_check_valid_username', 'Error Message');
       //
    }
    

    If you want to change the default error message for a specific rule, you can do so by invoking set_message with the first parameter as the rule name and the second parameter as your custom error. E.g., if you want to change the required error :

    $this->form_validation->set_message('required', 'Oops this %s is required');
    

    If by any chance you need to change the language instead of the error statement itself, create your own form_validation_lang.php and put it into the proper language folder inside your system language directory.

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

Sidebar

Related Questions

I have a login form in every page of a website so the user
On a website if I have a form where the user can input some
I have a website with a contact form. User submits name, email and message
I have this form: in header of my website: <% form_tag request.path, :method =>
On my website I have a PHP script which (when user enters a username
I have a website form that requires a US phone number input for follow
I have a website form that collects url of users to store in a
You have to have a form on your website for people to send an
I have a login form for my website. This login form have two text
I have a form where depending on the website's brand one of two input

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.