Welcome Guest, Not a member yet? Register   Sign In
Base Url is getting changed automatically
#1

[eluser]Ariful H Bhuiyan[/eluser]
Hi all

I am new in CodeIgniter and started to loving it. Trying to develop my test application but got some problem at beginning.

From view class, when I try to call any function in Controller class, my base url get changed automatically. Result is my css file become missing to app.

Example:
when I click on a button or link which is linked to a controller function, base url (http://localhost/greenimages) become (http://localhost/greenimages/contributor) where contributor is name of my controller.

Please help me to understand what is the problem and what is the solution with this.

Thanks
Ariful
#2

[eluser]LifeSteala[/eluser]
Hello,

You might like to take a read here Codeigniter URLs.

If your website is, www.greenimages.com and you click on the 'contributor' link, it's just like opening a standard link that takes you to www.greenimages.com/contributor.php.

The link above will explain it better though.

Good luck
#3

[eluser]Ariful H Bhuiyan[/eluser]
Thanks for answer but thats not what is the problem.

From my home page i can go easily to my Contributor page and than the url is greenimages.com/contributor
Than when I try to register a user, i enter User ID, Email, Password in text box and when click Submmit button (its inside a form tag) than the form action call the "contributor/register" function. the register() call a register() from model and data get saved in database. but than when i hover my mouse on Home link, it show the link is localhost/greenmages/contributor where Home was suppose to show localhost/greenimages.

In my config file config['base_url'] is set to 'http://localhost/greenimages'

I think I explained the situation in more details now.
#4

[eluser]LifeSteala[/eluser]
Can you show use the code for where your links are?
#5

[eluser]Ariful H Bhuiyan[/eluser]
Controller: Contributor
Code:
class Contributor extends CI_Controller{
    //put your code here
    public function  __construct() {
        parent:: __construct();

       /* $data['title']='Contributor';
        $data['keywords']='Photo Contributor, Stock Photographer';
        $data['description']='List of Photo Contributor in GREEN Images';
        $this->load->view('view_contributor',$data);
    */
        
    }//end construct

    public function index(){
        $data['title']='Contributor';
        $data['keywords']='Photo Contributor, Stock Photographer';
        $data['description']='List of Photo Contributor in GREEN Images';
        $this->load->view('view_contributor',$data);
    }//end index

    public function Registration(){

        $this->load->model('module_contributor','Contributor');
        $this->Contributor->Register();
        
        $this->Thanks();

    }//end Register

    public function Thanks()
    {
        $data['title']='Thanks';
        $data['keywords']='';
        $data['description']='';
        $this->load->view('Thanks.php', $data);
    }

} //end class Contributor
?>

View: From where I am clicking the submit button
Code:
<?php echo form_open("contributor/registration"); ?>
                <table border="0" width="100%">
                    <tr>
                        <td class="righttext"><label id="contributorID">User ID&nbsp;</label></td>
                        <td>&lt;input type="textbox" name="contributorID" value="&lt;?php echo set_value('contributorID'); ?&gt;"/&gt;&lt;/td>
                    </tr>
                    <tr>
                        <td class="righttext"><label id="email">Email&nbsp;</label></td>
                        <td>&lt;input type="textbox" name="contributorEmail" value="&lt;?php echo set_value('contributorEmail'); ?&gt;" /&gt;&lt;/td>
                    </tr>
                    <tr>
                        <td class="righttext"><label id="password">Password&nbsp;</label></td>
                        <td>&lt;input type="password" name="contributorPassword" value="&lt;?php echo set_value('contributorPassword'); ?&gt;" /&gt;&lt;/td>
                    </tr>
                    <tr>
                        <td class="righttext"><label id="cpassword">Confirm Password&nbsp;</label></td>
                        <td>&lt;input type="cpassword" name="cpassword"/&gt;&lt;/td>
                    </tr>
                    <tr>
                        <td class="righttext"><label id="Register">&nbsp;</label></td>
                        <td>&lt;input type="Submit" class="button" value="Register" name="Register"/&gt;&lt;/td>
                    </tr>
                </table>
            &lt;?php echo form_close(); ?&gt;
<a >Test</a>

#6

[eluser]CroNiX[/eluser]
Hard to guess what you are doing. You need to post actual code.
#7

[eluser]LifeSteala[/eluser]
Sorry, I'm looking for your view code that shows me how you marked up your navigation links not the code showing your form. Can you re-supply your full view code, maybe?
#8

[eluser]Ariful H Bhuiyan[/eluser]
Sure.. This code is from my header.php file

Code:
&lt;?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
?&gt;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;link type="text/css" href=&lt;?php base_url()?&gt;"css/stylesheet.css" rel="stylesheet"/&gt;
&lt;link type="text/css" href=&lt;?php base_url()?&gt;"css/style.css" rel="stylesheet"/&gt;&lt;!--for Nivo Slider--&gt;
&lt;link type="text/css" href=&lt;?php base_url()?&gt;"css/nivo-slider.css" rel="stylesheet"/&gt;&lt;!--for Nivo Slider--&gt;
&lt;meta name="keywords" content=&lt;?php echo $keywords;?&gt; &gt; &lt;/meta&gt;
&lt;meta name="description" content=&lt;?php echo $description;?&gt; &gt; &lt;/meta&gt;
&lt;title&gt;&lt;?php echo $title; ?&gt; - GREEN Images&lt;/title&gt;

&lt;/head&gt;

&lt;body&gt;
<div id="wrapper_main">
    <div id="header_main">
#9

[eluser]LifeSteala[/eluser]
Where is your navigation links Ariful?
#10

[eluser]CroNiX[/eluser]
[quote author="Ariful H Bhuiyan" date="1330376653"]... but than when i hover my mouse on Home link, it show the link is localhost/greenmages/contributor where Home was suppose to show localhost/greenimages.
[/quote]
The code that creates the links you mention here is what we need to see, since that is what is giving you the problem...

I'm guessing you are using a relative path, which would cause the problem you describe.




Theme © iAndrew 2016 - Forum software by © MyBB