Welcome Guest, Not a member yet? Register   Sign In
Using anchors instead of <a >
#1

[eluser]Unknown[/eluser]
Hi guys, I'm new to CI and I'm having a problem with using anchors in my viewers. I don't really know how to look for a solution on the web because I don't know what to look for specifically.

Here's what I have so far: I created subfolders in my controllers folder namely:
1. index folder
2. user folder
In the index folder, I created a controller named 'welcome.php', and I set it as the default controller. I have no problems displaying welcome_view.php using the welcome controller. Here's the content of the welcome_view.php
Code:
&lt;body&gt;
        <h1>Hello World!</h1>
        
        <ul>
            <li>&lt;?php echo anchor('user/login', 'Login') ?&gt;</li>
            <li>&lt;?php ?&gt;Register</li>
        </ul>    
        
    &lt;/body&gt;

In my 'user' folder, I created 2 controllers: 'register.php' and 'login.php'. What I wanted to do is when I click the "Login" link in my welcome_view.php, the login_view should be displayed, but with my present code it is not working. Am I using the anchor correctly?
I'm so confused. :/

Thanks for any help.
#2

[eluser]toopay[/eluser]
In your login controller, you should load the helper first...
Code:
$this->load->helper('url');
#3

[eluser]Unknown[/eluser]
Hi toopay, I believe that's not the problem because I have that in my config.php,
Code:
$autoload['helper'] = array('url','form');


I tried it though, but it doesn't work. When I click on the Login link, the welcome_view is still shown instead of the login_view.

Thanks.
#4

[eluser]toopay[/eluser]
Check your config.php for index file and base uri configuration. If you remove index.php from your uri, make sure you have a working htaccess for that.




Theme © iAndrew 2016 - Forum software by © MyBB