Welcome Guest, Not a member yet? Register   Sign In
Trouble with basic navigation.
#1

[eluser]duartix[/eluser]
I'm new to CI and besides other affairs, I'm having a few difficulties with basic navigation...

My default controller is like this:

applications/controllers/home.php

Code:
<?php
class Home extends CI_Controller {

    public function index() {
        $this->load->view('logintest');
    }
    
    public function login() {
        echo "hello!";
    }
}

the view is the following:

applications/views/login.php

Code:
\\<form method="post" action="home/login">
\\    <p>User:
\\        &lt;input type="text" id="username" name="username" class="login_input"&gt;
\\    </p>
\\    <p>&lt;input class ="login_button" type="submit" name="submit" id="login_button" value ="login"
\\    &lt;/p>
\\&lt;/form&gt;

The action gets cut in this post but it's: action="home/login"

My routes configuration is this:

Code:
$route['default_controller'] = 'home';

When I click the login button the browser navigates to http://localhost/glup2/home/login but instead of invoking the login method from the home controller it goes to a 404 error page instead.

What am I missing ?

Thanks in advance.
#2

[eluser]InsiteFX[/eluser]
Place php comment tags in front of the code then it will show all of it. ( // )
Code:
//  &lt;form name="input" action="home/login" method="post"&gt;
//       Username: &lt;input type="text" id="username" name="username" class="login_input" &gt;
//       &lt;input class="login_button" type="submit" name="submit" id="login_button" value="Submit"&gt;
//   &lt;/form&gt;

And now it doe's not work any more...
Had to paste it in again for it to work.
#3

[eluser]Otemu[/eluser]
What happens when you navigate directly using this url http://localhost/glup2/index.php/home/login if you can get to the page like this then you need to use ht.access to remove the index.php or change you form action to url above
#4

[eluser]InsiteFX[/eluser]
Or use the CodeIgniter form_helper
#5

[eluser]Unknown[/eluser]
Your form action should be "index.php/home/login". You can also use the CI built in function to open form:
form_open(). You will not need to add index.php if you use form_open() method.
&lt;?php
$this->load->helper('form'); //must load the form_helper before use
echo form_open('welcome/login'); //will produce&lt;form acti method="post" accept-charset="utf-8"&gt;

//to close form
form_close();
//more about form helper here
?&gt;
#6

[eluser]duartix[/eluser]
Thank you all once again.
All solutions proved useful and enlightening.




Theme © iAndrew 2016 - Forum software by © MyBB