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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:01:07+00:00 2026-06-18T04:01:07+00:00

I have a codeigniter controller with the following check() function to check username and

  • 0

I have a codeigniter controller with the following check() function to check username and password.

http://localhost/prakash/modules/index.php/login/login/login/login/login/login/check

and every time I submit the form (from the view), the above link is generated. How can I overcome it. I could have used redirect('login') in the controller instead of $this->load->view('login/login_form'); but in that way it wouldnt display the validation errors in the form.

My Controller is

function check(){

        $this->form_validation->set_rules('username', 'Username', 'required');
        if($this->form_validation->run()==FALSE){
            $this->load->view('login/login_form');
        }else{
            $this->load->model('loginModel');
            $query = $this->loginModel->validate();
            if($query){
                $data = array('username' => $this->input->post('username'),
                               'is_logged_in' => true
                            );
                $this->session->set_userdata($data);
                //redirecting to appropriate page 
                redirect('success');
            }else{
                $this->session->set_flashdata('loginCheck','Username/Password Comination Incorrect!');
                redirect('login');
            }
        }

    }

My view is

<section class="main">
<form class="form-1" action="login/check" method="post">
    <?php echo "<p class=\"text-error\">{$this->session->flashdata('loginCheck')}</p>"; ?>
    <?php echo validation_errors(); ?>
    <p class="field">
        <input type="text" name="username" placeholder="Username or email">
        <i class="icon-user icon-large"></i>
    </p>
        <p class="field">
            <input type="password" name="password" placeholder="Password">
            <i class="icon-lock icon-large"></i>
    </p>
    <p class="submit">
        <button type="submit" name="submit"><i class="icon-arrow-right icon-large"></i></button>
    </p>
</form>
</section>
  • 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-18T04:01:09+00:00Added an answer on June 18, 2026 at 4:01 am

    The problem is with the action attribute of the form tag

    Change

    <form class="form-1" action="login/check" method="post">
    

    To

    <form class="form-1" action="/login/check" method="post">
    

    Or better (if you are using the url helper)

    <form class="form-1" action="<?php echo base_url() ?>login/check" method="post">
    

    Why is it happening?

    You are using a value that is relative to the path of the current url.

    HTML form action Attribute

    Example 1

    • Page
      • http://www.example.com/
    • Form
      • <form class="form-1" action="login/check" method="post">
    • Will post to
      • http://www.example.com/login/check

    Example 2

    • Page
      • http://www.example.com/login/
    • Form
      • <form class="form-1" action="login/check" method="post">
    • Will post to
      • http://www.example.com/login/login/check

    Example 3

    • Page
      • http://www.example.com/login
    • Form
      • <form class="form-1" action="/" method="post">
    • Will post to
      • http://www.example.com/
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am fairly new to codeigniter. I have the following code in my views/check_availability/index.php
In my Codeigniter controller have the following private function which validates file uploads. private
I have the following url.. http://localhost/ci/site_controller/home I want to remove site_controller controller from url
I am using Codeigniter message library. In my controller I have the following code
I have 2 functions/methods in the same controller in CodeIgniter like this: public function
I have this function on my controller (Im using CodeIgniter) that reads the database,
Fellow coders, i have a function in a codeigniter controller that accepts a couple
I am trying to extend the CodeIgniter controller. I have created MY_Controller.php file, the
I'm following the tutorial here: http://www.jotorres.com/2012/01/using-jquery-and-ajax-with-codeigniter/ For my view, I have: <script type=text/javascript src=<?php
Please see the following controller in CodeIgniter 2 <?php class user extends CI_Controller {

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.