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

[eluser]davy_yg[/eluser]
Hello,

I am trying to create a login controller through CI:

views/admin/login.php

Code:
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
&lt;html  xml:lang='en' lang='en'&gt;

&lt;head&gt;    
    &lt;title&gt;Jotorres Login Screen | Welcome &lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    <div id='login_form'>
        &lt;form acti echo base_url();?&gt;login/process' method='post' name='process'&gt;
            <h2>User Login</h2>
            <br />            
            <label for='username'>Username</label>
            &lt;input type='text' name='username' id='username' size='25' /&gt;&lt;br />
        
            <label for='password'>Password</label>
            &lt;input type='password' name='password' id='password' size='25' /&gt;&lt;br />                            
        
            &lt;input type='Submit' value='Login' /&gt;            
        &lt;/form&gt;
    </div>
&lt;/body&gt;
&lt;/html&gt;


I wonder what this code means:

redirect_admin(); ?

routes.php

Code:
$route['admin/login/'] = 'admin/clogin';


controllers/admin/clogin.php

Code:
&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/* Author: Jorge Torres
* Description: Login controller class
*/
class Login extends CI_Controller{
    
    function __construct(){
        parent::__construct();
    }
    
    public function index(){
        // Load our view to be displayed
        // to the user
        $this->load->view('admin/login');
    }

  public function process(){
        // Load the model
        $this->load->model('login_model');
        // Validate the user can login
        $result = $this->login_model->validate();
        // Now we verify the result
        if(! $result){
            // If user did not validate, then show them login page again
            $this->index();
        }else{
            // If user did validate,
            // Send them to members area
            redirect('home');
        }        
    }
}
?&gt;


I wonder why I cannot see the login page just by typing: localhost/indonusaCI/admin/clogin/ ?

#2

[eluser]Tpojka[/eluser]
Name of file must be same with name of class.
Code:
clogin != Login
#3

[eluser]davy_yg[/eluser]

I change the class name to :

class Clogin extends CI_Controller{


and try typing: localhost/IndonusaCI/admin/clogin

and still unable to access the website login page.

Object not found!

Why is it?
#4

[eluser]Tpojka[/eluser]
Code:
public function index(){ 
       // Load our view to be displayed       
       // to the user
        $this->load->view('admin/clogin');   
 }

You have to check and read whole code to change all affected variables/names. I've made this one for you now.
#5

[eluser]noideawhattotypehere[/eluser]
[quote author="Tpojka" date="1382324797"]
Code:
public function index(){ 
       // Load our view to be displayed       
       // to the user
        $this->load->view('admin/clogin');   
 }

You have to check and read whole code to change all affected variables/names. I've made this one for you now.[/quote]

and why would you change views filename when its all about the controller? rofl.
#6

[eluser]Tpojka[/eluser]
There is no admin/login file actually, but admin/clogin could redirect somewhere?
Whole code is made from anothere code and variables are not changed consistently.
#7

[eluser]davy_yg[/eluser]
I finally able to open the page by typing:

http://localhost/IndonusaCI/index.php/admin/clogin

Do I have to write the index.php also to view the admin page ?

The url doesn't seem user friendly. Is it possible to view the admin page just by typing localhost/IndonusaCI/admin ? How is that possible ?
#8

[eluser]35mm[/eluser]
[quote author="davy_yg" date="1382348354"]I finally able to open the page by typing:

http://localhost/IndonusaCI/index.php/admin/clogin

Do I have to write the index.php also to view the admin page ?

The url doesn't seem user friendly. Is it possible to view the admin page just by typing localhost/IndonusaCI/admin ? How is that possible ?[/quote]

Here read the manual http://ellislab.com/codeigniter/user-gui.../urls.html
You can get nice, friendly URLs
#9

[eluser]davy_yg[/eluser]

I replace my .htaccess with the following codes:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Then, whenever I type this: localhost/indonusaCI/admin/clogin the url suddenly change to localhost/xampp , I wonder why ?
#10

[eluser]Tpojka[/eluser]
Maybe, second line should be something like

RewriteBase /indonusaCI/




Theme © iAndrew 2016 - Forum software by © MyBB