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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:25:21+00:00 2026-05-27T03:25:21+00:00

I have a codeigniter application.This is my code in view page. function click_next(){ var

  • 0

I have a codeigniter application.This is my code in view page.

function click_next(){

var aname = $("#txtuname").val();
var apasswd = $("#txtupass").val();
if(aname == ''){
    $("#error_val").css("display","block")
    $("#error_val").html("user name required");
    });
}else if(apasswd == ''){
    $("#error_val").css("display","block")
    $("#error_val").html("password required");
}else{ 
    var cnt=$("#alogin").serialize();
    $.ajax({  
        type: "POST",  
        url: "<?php echo base_url();?>index.php/admin/adminLogin/",
        data: cnt,
        success: function(msg){
        if(msg==1){
        window.location="<?php echo base_url();?>index.php/admin/adminHome/";
        }
        else{
        $("#error_val").css("display","block")
        $("#error_val").html(msg);
        return false;
                }
            }  
        });
}

}

Here alogin is the name of the form and url: "<?php echo base_url();?>index.php/admin/adminLogin/" is the function path in controller page.

This is the code in Controller page

function adminLogin(){
         $this->adminmodel->admin_login();

    }

This is the code in Model page

function admin_login(){
        $adminname=$this->input->post('txtuname');
        $adminpass=$this->input->post('txtupass');
        $adminp_decr=md5($adminpass);
        $this->db->where('varuname',$adminname);
        $this->db->where('varpassword',$adminp_decr);
        $query = $this->db->get('tbladmin');
        $row=$query->row();
        if($row==TRUE){
            $adminname=$row->varuname;
            $id=$row->intaid;
            $userdata = array(
                        'ausername=' =>$adminname,
                        'aid' => $id,
                        'logged_in' => TRUE
                       );

            $this->session->set_userdata($userdata);
            echo 1;
        }
        else
        {
            echo "Invalid user name or password";     
        }

    }

But when i click on the Login buttton nothing will happen(the click_next() is called and given admin,admin as username ,password).What is the reason?This is working in our server But not working in client’s server?

  • 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-27T03:25:21+00:00Added an answer on May 27, 2026 at 3:25 am

    Since you’re posting to the controller method, I would recommend grabbing the POST variables in that method and passing them via parameters to the model function. According to MVC, the controller should be working with POST variables and not the model.

    Try this:

    function adminLogin(){
         $adminname=$this->input->post('txtuname');
         $adminpass=$this->input->post('txtupass');
    
         if (strlen($adminname) > 0 && strlen($adminpass) > 0)
             echo $this->adminmodel->admin_login($adminname, $adminpass);
         else
             echo "you didn't enter anything.... duh.";
        }
    
    
    function admin_login($adminname="", $adminpass=""){
            $adminp_decr=md5($adminpass);
            $this->db->where('varuname',$adminname);
            $this->db->where('varpassword',$adminp_decr);
            $query = $this->db->get('tbladmin');
            $row=$query->row();
            if($row==TRUE){
                $adminname=$row->varuname;
                $id=$row->intaid;
                $userdata = array(
                            'ausername=' =>$adminname,
                            'aid' => $id,
                            'logged_in' => TRUE
                           );
    
                $this->session->set_userdata($userdata);
                return 1;
            }
            else
            {
                return "Invalid user name or password";     
            }
    
        }
    

    It’s a minor change, but the code adheres more to MVC principles. Plus, I suspect that your POST variables might not be making it past the call to the model’s admin_login() method.

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

Sidebar

Related Questions

This is my uploadinfg files code in codeigniter application function upload_logo(){ $ex=$_FILES['uploadfile']['name']; $epld=explode('.',$ex); $filename=date(mdyHis)...$epld[1];
I have this function on my controller (Im using CodeIgniter) that reads the database,
I have a codeigniter application.In that i call the controller function using ajax/jquery.But when
I am getting echoed Disallowed Key Characters. in my CodeIgniter application when I have
I am using Codeigniter to develop an application, and have been reading bits about
I have a codeigniter code that is working on local Apache installation. But it
I have a validation function I'm using inside of codeigniter. function valid_image() { if
I already have an express checkout integrated with my Codeigniter application. Now I want
I'm moving towards an ORM for my codeigniter application and have chosen datamapper .
I have an error_codes.php file located in application/libraries I have it autoloaded when CodeIgniter

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.