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 8653195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:29:07+00:00 2026-06-12T14:29:07+00:00

I am really close to giving up on the native form validation error functions

  • 0

I am really close to giving up on the native form validation error functions in Code Igniter as I am having great trouble getting them to work properly. My logic seems straight as an arrow, however the behavior of the error posing is really throwing me for a loop based off of my logic.

so here is a list of what is going on.

*When I submit the form without filling out any fields = the invalid email and password errors pose as they should

*When I enter the CORRECT email and leave password field blank = the proper invalid password error poses as it should

*When I enter the correct email and an incorrect password = the page loads white

*When I enter just the password field = the invalid email comes up

*When I enter gibberish email and leave password blank = invalid email comes up

There are many combinations of false hood that are going on.

I am also wanting to make the emails unique to where it recognizes if the email being entered does not exist in the database.

I have been stuck on this for far too long and really need some help. I am new with code-igniter and am really confused as to why this is happening. Any help is greatly appreciated.

Here is my code:

Form:

<?php
echo form_open('auth/validate_credentials_login');
echo "<span class='errors_login'>";
echo form_error('email_login');
echo "</span>";
echo form_label('', 'Email', 'email_login');
$data = array( 'name' => 'email_login', 'class' => 'input', 'placeholder' => 'Email');
echo form_input($data, set_value('email_login'));
echo "<span class='errors_login'>";
echo form_error('password_login');
echo "</span>";
echo form_label('', 'Password;', 'password_login');
$data = array( 'name' => 'password_login', 'class' => 'input', 'placeholder' => 'Password');
echo form_password($data, set_value('sha1(password_login)'));
echo form_submit('submit_login', 'Login');
echo form_close();
?>

Controller:

function validate_credentials_login()
        {
            $this->load->library('session');
            $this->load->helper(array('form','url'));
            $this->load->model('user_model', 'um');
            $this->load->library('encrypt');
            $this->load->library('form_validation');
            $this->form_validation->set_rules('email_login', 'Email', 'required');
            $this->form_validation->set_rules('password_login', 'Password', 'required');
            $login = $this->input->post('submit_login');

            if($login) {
                if($this->form_validation->run() == FALSE)
                {
                    $data['main_content'] = 'home/home_page';
                    $this->load->view('includes/templates/home_page_template', $data);
                }
                else 
                {
                    $user = $this->um->validate_home_login(array('email' => $this->input->post('email_login')));

                        if($user->password == $this->encrypt->sha1( $user->salt .           $this->encrypt->sha1($this->input->post('password_login')))) {
                            $this->session->set_userdata(array(
                                'email' => $this->input->post('email_login')
                                    ));
                                redirect('account/edit');
                                exit;
                            }
                        }
                    }
                }

thanks in advance!

  • 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-06-12T14:29:08+00:00Added an answer on June 12, 2026 at 2:29 pm

    When I enter the correct email and an incorrect password = the page loads white

    That’s because you have no else condition here:

    if($user->password == $this->encrypt->sha1($user->salt.$this->encrypt->sha1($this->input->post('password_login')))) {
            $this->session->set_userdata(array(
                'email' => $this->input->post('email_login')
            ));
            redirect('account/edit');
            exit;
        }
    }
    // do nothing?
    

    Everything else in your list sounds like expected behavior, but you might need to make sure that $this->um->validate_home_login() is doing what it should.

    As a side note, no need to exit after calling redirect(), it does that for you.

    Also, set_value('sha1(password_login)') looks fishy to me, I don’t think it does what you think. It will set the password value to the literal string sha1(password_login). I don’t suggest you prepopulate the password field at all – just leave it empty.

    CI’s form validation is definitely not broken, it actually works quite well, so don’t get frustrated. It might be a good idea to review the documentation and experiment with something simpler until you can get everything working properly.

    I am also wanting to make the emails unique to where it recognizes if the email being entered does not exist in the database.

    Check out the is_unique rule:

    http://ellislab.com/codeigniter/user_guide/libraries/form_validation.html#rulereference

    $this->form_validation->set_rules(
        'email_login',
        'Email',
        'required|is_unique[your_table.your_email_field]'
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

getting really close to running my first stored procedure. This one compiles but when
I'm really having trouble closing my console application with FreeGLUT. I would like to
I'm having trouble with my code. the logic of my code is, when it
I am really close to finishing up on a project that I've been working
I may be waaaay off, or else really close. Either way, I'm currently SOL.
Really simple but just not getting it. I want to reference a view by
I thought that I was really close to release this new App of mine
I have the lat/lon of 2 points on the earth. They are really close
I found all sorts of really close answers already, but not quite. I need
How can one be sure that a function is really random or as close

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.