codeigniter:how to check user name and password
<p>if login failed then how to redirect same login page &amp; display wrong username
                  
                        $('#login_form').submit(function (e)
                        {
                            e.preventDefault();
                            var uname = $('#uname').val();
                            var upassword = $('#upassword').val();
                            if (uname == "" || upassword == "")
                            {
                                $('#errmessage').show().html('All Fields are required');
                            } else {
                                $('#errmessage').html("").hide();
                                $.ajax({
                                    type: "POST",
                                    url: "User_controller/login_autho/",
                                    datatype: 'json',
                                    data: {uname: uname, upassword: upassword},
                                    success: function (data) {
                                        $('#successmessage').fadeIn().html(data),
                                                window.location.replace("/User_controller/profile");
                                    }
                                });
                            }
                        });
                    
To check login autho and if success then redirect to profile page   </p>

<pre><code>public function login_autho() {
                $data = array(
                    'uname' =&gt; $this-&gt;input-&gt;post('uname'),
                    'upassword' =&gt; $this-&gt;input-&gt;post('upassword')
                );

                $result = $this-&gt;login_model-&gt;login_user($data);

                if ($result == TRUE) {
                    $this-&gt;session-&gt;set_flashdata('success', 'Success Login');
                    $this-&gt;load-&gt;view('user/success');
                 //   echo 'su';
                } else {
                    //$this-&gt;session-&gt;set_flashdata('error', 'Invalid Username or Password');
                    //echo 'invalid user';
              // echo json_encode(false);
                    }
            }

            public function profile() {
                $this-&gt;load-&gt;view('header');
                $this-&gt;load-&gt;view('user/success');
            }
</code></pre>