Welcome Guest, Not a member yet? Register   Sign In
help require for redirecting
#1

[eluser]doforumda[/eluser]
Hi, I am new to codeigniter and making a login script in CI. When user successfully logs in then I want him to be redirected to home function inside this controller. But the problem is that it displays this error
Code:
The requested URL /sign_in/home was not found on this server.

here is my code. This is sign_in.php page or controller
Code:
class Sign_in extends CI_Controller {
    function __construct() {
        parent::__construct();
    }
    public function index()
    {
        $this->load->view('signin');
    }
    function home() {
        //$this->load->view('home');
        echo "Home";
    }
    function signin_validation() {
        extract($_POST);
        $error = 'yes';
        $errorType = 'no-type';
                    $password_md5 = md5($signin_password);
                    $user_data = array(
                        'email' => $signin_email,
                        'password' => $password_md5
                    );
                    $signin = $this->Signin_model->signin_process($user_data);
                    if($signin) {
                        $this->session->set_userdata($signin);
                        //redirect('/sign_in/home');
                        $error = 'no';
                        $msg = 'success';
                    } else {
                        $errorType = 'email';
                        $msg = "Invalid email or password!";
                    }
        $JSON_array = array('msg' => $msg, 'error' => $error, 'errorType' => $errorType);
        $JSON_response = json_encode($JSON_array);
        header('Contents: type/json');
        echo $JSON_response;
    }
}
here is my form. But I am submitting this form using jquery function submit like this
Code:
$('#signin_form').submit();
Code:
<form id="signin_form" class="in_up_forms" name="signin_form" action="<?php echo base_url(); ?>sign_in/home" method="post">
                <div>
                    <label>Email:</label>
                    &lt;input type="text" id="signin_email" name="signin_email" /&gt;
                </div>
                <div>
                    <label>Password:</label>
                    &lt;input type="password" id="signin_password" name="signin_password" /&gt;
                </div>
                &lt;input type="button" name="signin_button" id="signin_button" value="Sign in" /&gt;
                <div id="signin_error" class="in_up_errors"></div>
            &lt;/form&gt;
help please
#2

[eluser]tomcode[/eluser]
Use site_url() instead of base_url()
Code:
&lt;?php echo site_url('sign_in/home'); ?&gt;
#3

[eluser]doforumda[/eluser]
tomcode thanks it works but the problem is with url now. It displays this url
Code:
.../index.php/sign_in/[email protected]&signin_password=123456
in url bar on browser. How can i make it like this?
.../index.php/sign_in/home
#4

[eluser]doforumda[/eluser]
its ok thanks i just changed method='post' so now it works.




Theme © iAndrew 2016 - Forum software by © MyBB