1

I Have issue on base_url in codeigniter. I googling to find a solution but no luck. I Hope this forum can help find the solution.

my I issue is base_url not translated properly.

this is my config.php

$config['base_url'] = 'http://192.168.1.181/asset_apps';

$config['index_page'] = '';

$config['uri_protocol'] = 'AUTO';

this is my view :


<!DOCTYPE html>
<html>


 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <!-- Meta, title, CSS, favicons, etc. -->
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

   <title>Login To Asset Management</title>

  <!-- Bootstrap core CSS -->

  <link href="<? echo base_url('gentelella/vendors/bootstrap/dist/css/bootstrap.min.css') ?>" rel="stylesheet">

  <link href="<? echo base_url('gentelella/vendors/font-awesome/css/font-awesome.min.css') ?>" rel="stylesheet">
  <link href="<? echo base_url('gentelella/documentation/css/animate.min.css') ?>" rel="stylesheet">

  <!-- Custom styling plus plugins -->
  <link href="<? echo base_url('gentelella/production/css/custom.css') ?>" rel="stylesheet">
  <link href="<? echo base_url('gentelella/vendors/iCheck/skins/flat/green.css') ?>" rel="stylesheet">


  <script src="<? echo base_url('gentelella/vendors/jquery/dist/jquery.min.js') ?>"></script>

 </head>
 <body style="background:#F7F7F7;">
    <div class="">
      <a class="hiddenanchor" id="tologin"></a>

      <div id="wrapper">
        <div id="login" class="animate form">
            <section class="login_content">
                <?php echo validation_errors(); ?>
               <!--  <?php  //echo form_open('application/controllers/verifylogin'); ?> -->
           <form class="form-default" method="POST" action="<? echo base_url('verifylogin'); ?>">  
              <h1>Login Form</h1>

                  <div>
                    <input type="text" class="form-control" placeholder="Username" id="username" name="username" required=""/>  
                  </div>
                  <div>
                    <input type="password" class="form-control" placeholder="Password" id="password" name="password" required=""/>  
                  </div>

                       <!---<a class="btn btn-default submit" type ="submit" value ="Login" href="<?php //echo site_url('verifylogin') ?>">Log In</a>  -->
                     <a><input class = "btn btn-default" align="center" type = "submit" value = "Login"></a>

                  <div class="clearfix"></div>
                      <br />
                    <div>
                      <h1><i class="fa fa-paw" style="font-size: 26px;"></i> Asset Management </h1>
                      <p>©2016 IT Department</p>
                  </div>
                       <!--<label for="username">Username:</label>
                       <input type="text" size="20" id="username" name="username"/>
                       <br/>
                       <label for="password">Password:</label>
                       <input type="password" size="20" id="passowrd" name="password"/>
                       <br/>
                       input type=<"submit" value="Login"/> -->
            </form>


        </section>           
        </div>

      </div>              
    </div>     
 </body>
</html>

But When I run it on the browser and view page source, the base_url not translated or change to the base_url that I set on config.

and when I click the link on th view page source error occured :

Forbidden

You don't have permission to access /asset_apps/< on this server.

and the link on a toolbar like this :

http://192.168.1.181/asset_apps/%3C?%20echo%20base_url(%27gentelella/vendors/bootstrap/dist/css/bootstrap.min.css%27)%20?%3E

Please Help.

Thank you in Advance.

Best Regards,

Dian

Dian.Y
  • 105
  • 1
  • 5
  • 15

3 Answers3

0

Did you check that short tag is allowed or not by PHP?

You can use full tags so there will be no problem in future

<?php echo base_url('url'); ?>

Also add last extra / in following

$config['base_url'] = 'http://192.168.1.181/asset_apps/';

Check this for Short tag

Community
  • 1
  • 1
Shri Suresh
  • 463
  • 1
  • 5
  • 20
0

First of all the php tags should be like this <?php echo base_url(); ?> and not like this <? echo base_url(); ?>

Secondly, you must make sure that you have loaded the url helper

You can autoload url helper by editing autoload.php in the config directory like this

$autoload['helper'] = array('url','form');

Hope this will help you.

muya.dev
  • 966
  • 1
  • 13
  • 34
0

In order to use base_url(), you must first have the URL Helper loaded. This can be done either in application/config/autoload.php (on or around line 67):

$autoload['helper'] = array('url');

Or, manually:

$this->load->helper('url');
Mayank Pandeyz
  • 25,704
  • 4
  • 40
  • 59