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

[eluser]Unknown[/eluser]
Im having problem with the image directory.

I have a controller file named login.php

Code:
<?php

class Login extends Controller{
    
    function index()
    {
        $data['main_content'] = 'login_form';
        $this->load->view('includes/template', $data);
    }
    
    function validate_credentials()
    {
        $this->load->model('membership_model');
        $query=$this->membership_model->validate();
        
        if($query)
        {
            $data = array(
                          'username' => $this->input->post('username'),
                          'is_logged_in' => true
                          );
            
            $this->session->set_userdata($data);
            redirect('site/members_area');
        }
        else
        {
            $this->index();
        }
    }
    
    function signup()
    {
        $data['main_content'] = 'signup_form';
        $this->load->view('includes/template',$data);
    }
    
}

when the website first loads, it automaticlly loads this controller with the default function of "index"

Code:
function index()
    {
        $data['main_content'] = 'login_form';
        $this->load->view('includes/template', $data);
    }

which loads the login form.

Code:
<div id="ab_box_title">
    img src="images/login/titlebar.png" alt="Login"/> // PROBLEM WITH THESE IMAGES
</div>

&lt;?php
                                    
   echo form_open('login/validate_credentials');
   echo form_input('username','Username');
   echo form_password('password','Password');
                                    
?&gt;
   <br/>
   &lt;input type="image" src="images/index/login_submit.png" name="submit" alt="Submit button"&gt; // PROBLEM WITH THESE IMAGES

the problem is here when i press submit. After i press submit with the wrong username and password, it "$this->index();".

then the url becomes http://localhost/demo/index.php/login/va...redentials

after that, the images wont show up anymore unless i change "images/" to "../../images"
but that makes the default page "http://localhost/demo/index.php" missing the images

How do i approach to fix this?
without using absolute links.
#2

[eluser]InsiteFX[/eluser]
Look in the user guide for the html helper img tag.

Enjoy
InsiteFX
#3

[eluser]Unknown[/eluser]
So there is no other way then generate an absolute link? Which the IMg helper does
#4

[eluser]InsiteFX[/eluser]
Well you could also use the url helper and do a echo base_url();assets\images or were ever you have them.

Enjoy
InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB