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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:19:17+00:00 2026-06-10T21:19:17+00:00

wondering if anyone can guide me to what ive done wrong (or need to

  • 0

wondering if anyone can guide me to what ive done wrong (or need to do) and think the problem is in my routes file. When the user is displayed the login form and for example they get their username wrong after submit the url displays as this: http://localhost:8888/codeigniter/login/login_validation. When the are successful and log into the admin area (which pulls news articles from the db) this url is still shown. I am wondering if there is a way to make it to http://localhost:8888/codeigniter/news. I have looked in my routes folder and i tried to use ‘wildcards’ and was unsuccessful. Here is my code for reference, any other info or files needed let me know! Thanks.

CONTROLLER:

  class Login extends CI_Controller {

    public function __construct() {
        parent::__construct();

    }

        public function index() {
            $this->load->view('login');
    }


    //Validate login area
    public function login_validation() {
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username', 'Username', 'trim|required|xss_clean|callback_username_check');
        $this->form_validation->set_rules('password', 'Password', 'required|xss_clean|callback_password_check');

          if($this->form_validation->run() == FALSE) {
             //Field validation failed.  User redirected to login page
             $this->index();

             }else{
                 $this->load->model('user_model');
                 $query = $this->user_model->login_details();

                 // if the user's credentials validated...
                if($query) {
                    $data = array(
                        'username' => $this->input->post('username'),
                        'is_logged_in' => true
                    );

                    $this->session->set_userdata($data);
                    redirect('news');

                }else{
                 $data['error'] ="Invalid Username or Password";
                 $this->load->view('login',$data);  
                }

            }
    }

            function logout() {
       $this->session->sess_destroy();
       $this->index();
}

}

login_details function from user_model.php

           function login_details() {
        $this->db->where('username', $this->input->post('username'));
        $this->db->where('password', md5($this->input->post('password')));
        $query = $this->db->get('login');

        if($query->num_rows == 1){
            return true;
        }
    }       
  • 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-10T21:19:19+00:00Added an answer on June 10, 2026 at 9:19 pm

    If you’re logging into any kind of system, you’re going to need to store a session using CodeIgniter’s Session class. Provided controllers/news.php exists, you can set the session and immediately just perform a redirect with redirect('news');. No need to $this->load->view() because this logic will be in news.php‘s index anyway and you’d be duplicating code.

    I’m not sure what $this->user_model->login_details() is returning, but I’m assuming false or null because you say CodeIgniter is sending you back to the login view. Head into the login_details() function and make sure things are working properly (you might want to post it too). Also, post your routes.php file for us if you made changes just in case.

    On a side note: Space is a valid password character, don’t trim it or folks with leading or trailing space’s in their passwords won’t be able to get in 😉

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

Sidebar

Related Questions

Wondering if anyone can suggest a good file replication tool that will replicate across
I am wondering if anyone can offer any advice towards solving this problem. I
Wondering if anyone can help me with this slight problem i'm having. I am
Just wondering if anyone can optimize this usortMonths() function to be better? Basically I
Was wondering if anyone can point me to an open source java quant library
I was wondering if anyone can point me in the right direction. I have
I was wondering if anyone can post an example of how to get a
I am wondering if anyone can suggest solutions for adding together datetimes in mysql?
I am wondering if anyone can point me in the direction of learning how
I'm new to Oracle and I'm wondering if anyone can tell me what is

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.