Welcome Guest, Not a member yet? Register   Sign In
Login page
#1

[eluser]vahidsamimi[/eluser]
hi all
i'm beginner in codeigneter.
i want to create login page but i have problem and this is not work!.
i use ver 2.1.3

when i click "login" button , it always shows, "the requested URL ../user/login was not found on this server.

my user.php is :
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class User extends CI_Controller{

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

    public function index()
    {
        $this->load->view('view_login');
    }
    public function login()
    {
        echo "Log in";
    }
}

my view_user.php
Code:
<div id="form_login" >
    &lt;?php echo form_open(base_url() .'user/login'); ?&gt;
    <ul>
        <li>
            <label>Username : </label>
            <div>
                &lt;?php echo form_input(array('id'=>'username','name' => 'username')); ?&gt;
            </div>
        </li>
        <li>
            <label>Password : </label>
            <div>
                &lt;?php echo form_password(array('id'=>'password','name'=>'password')); ?&gt;
            </div>
        </li>
        <li>
            &lt;?php echo form_submit(array('name' =>'submit'),'Login'); ?&gt;
        </li>
    </ul>
    &lt;?php echo form_close(); ?&gt;

    </div>

my routes.php :
Code:
$route['default_controller'] = "user";
$route['404_override'] = '';

config.php :
Code:
$config['base_url'] = 'http://localhost/code';


$config['index_page'] = '';
#2

[eluser]InsiteFX[/eluser]
Your missing the ending slash / on the end of your config base_url

If you leave it blank '' CI will figure it out for you.
#3

[eluser]vahidsamimi[/eluser]
thanks InsiteFX
but stil not work!!!

Sad
#4

[eluser]InsiteFX[/eluser]
When checking view code you need to place and exit after it or it will get over written.

Code:
public function login()
    {
        echo "Log in";

        exit();
    }

Form_open should be like this:
Code:
&lt;?php echo form_open('user/login'); ?&gt;




Theme © iAndrew 2016 - Forum software by © MyBB