Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all 14148 articles
Browse latest View live

where is the function _exception_handler writing to?

$
0
0
I see:
PHP Code:
        $_error =& load_class('Exceptions''core');
        
$_error->log_exception('error''Exception: '.$exception->getMessage(), $exception->getFile(), $exception->getLine()); 
I just don't know where that would be writing to on my ubuntu server?

why's that no data showing on my sidebar,even if it's on my admin or user side?

$
0
0
this is the picture of my sidebar:
[Image: qyY3Rfr]
this is my code in my sidebar:
Code:
<aside class="main-sidebar">
   <!-- sidebar: style can be found in sidebar.less -->
   <section class="sidebar">
     <!-- Sidebar user panel -->
     <br><br>
     <!-- sidebar menu: : style can be found in sidebar.less -->
     <ul class="sidebar-menu" data-widget="tree">
       <?php
        if($this->session->type == "admin"){ ?>
          <li>
           <a href="<?php echo base_url(); ?>userdata">
             <i class="fa fa-users"></i><span>User Data</span>
           </a>
         </li>
         <li>
           <a href="<?php echo base_url(); ?>category">
             <i class="fa fa-list-alt"></i><span>Category</span>
           </a>
         </li>
         <li>
           <a href="<?php echo base_url(); ?>brand">
             <i class="fa fa-book"></i><span>Brands</span>
           </a>
         </li>
         <li>
           <a href="<?php echo base_url(); ?>product">
             <i class="fa fa-product-hunt"></i><span>Products</span>
           </a>
         </li>
         <li>
           <a href="#">
             <i class="fa fa-first-order"></i><span>Orders</span>
           </a>
         </li>
       <?php
       } elseif($this->session->type == "user"){ ?>
         <li>
           <a href="#">
             <i class="fa fa-first-order"></i><span>Orders</span>
           </a>
         </li>
       <?php
       }
       ?>
     </ul>
   </section>
   <!-- /.sidebar -->
 </aside>


then this is my code in my login:
Code:
$this->form_validation->set_rules('username', 'Username', 'trim|required');

$this->form_validation->set_rules('password', 'Password', 'trim|required');
if($this->form_validation->run() == TRUE){
$username = $this->input->post('username');
$password = $this->input->post('password');
$email = $this->input->post('email');
$user_id = $this->login_model->login($username, $password);
if($user_id){
$session = array(
'user_id' => $user_id,
'username' => $username,
'email' => $email,
'logged_in' => true
);
$this->session->set_userdata($session);
foreach ($user_id as $users){
if($users->type == admin){
redirect(base_url() . 'category');
} elseif($users->type == user){
redirect(base_url() . 'profile');
}
}

Community Auth - Use to selectivly display content on page

$
0
0
Hi all,

thanks for this nice plugin, i had some trouble setting it up but reading helped me big time.

One thing i could not achieve though was content on a page depending on a role.

i tried using 


PHP Code:
<?php
    
if( $this->require_role('admin') ) {
        echo 
'<a href="'.echo base_url(). 'index.php/advertsize/">Anzeigengr&ouml;&szlig;e</a>';
    }
?>

but this leads to the error:

Fatal error: Call to undefined method MY_Loader::require_role() in ...

Which i think is because i am calling this from a .php page and not a Controller.

How would i implement such a thing?

Thanks a lot.
x

Keeping eye on competing frameworks

$
0
0
I like to keep eye out for what's going on in web development scene, so been watching some Laravel stuff lately.

Recent talk from Laracon AU, it's about migrating to Laravel, but for some reason he's basing it exclusively on getting out of CodeIgniter project, so it was interesting to see how developers using other frameworks see CodeIgniter.

https://www.youtube.com/watch?v=R_0Q5rXGHXg

Looks like he's main points why people should move away from quote "legacy framework like CodeIgniter" are:
- it doesn't support Composer
- it doesn't have templating engine
- it doesn't have any automated framework / backend / unit tests implemented
- it doesn't have any automated frontend / in-browser tests implemented, which Laravel has available via Laravel Dusk
- models implement SQL queries and doesn't use Eloquent, and that is making queries slower

Mind you, he's examples are all based CI 2.x, which obviously is older than 3.x, let alone new shiny 4.0.

From what I've seen most of these points will be made invalid by CI4 out of the box, minus probably only in-browser testing?

Problema Con CI 3

$
0
0
Hola a todos, primero dar las gracias por este foro, es una buena iniciativa y me uno para ayudar en todo lo que pueda sobre CI.

Soy nuevo en el foro asi que pido perdón si este post no deberia estar aquí o ya ha sido resuelto etc.

Tengo un pequeño problema con la redireccion en CI. Todo a fucnionado bien hasta que migramos de servidor, Desde entonces esta linea ha dejado de funcionar. "redirect('controller');" he probado con poner la ruta entera, con la opción refres, y nada. no redirige hacia ningún lado.

Alguien me puede ayudar o tiene alguna idea de que puede estar pasando?.



PEgo el codigo aquí.


public function vaciar_carrito()
    {
        $this->cart->destroy();
        redirect('carrito');
        
    }



como veis no tiene mucha complicación. Gracias espero vuestra ayuda.

Getting and Comparing Data in Foreach best pratice

$
0
0
Hi,

I'm asking for your help to understand if i'm doing something in the correct way or if exist another method to do this.

I have a foreach in my view to retrieve rows and their data from a specific table.

One of the columns table is an ID, and i want to use that ID to get values from another table.

What i did after the foreach was query all my data from the second table in a model and pass it in the controller to the view and nest another foreach to see if the ID exists in that second table and list the data.

My question is, it's possible to pass the ID from the first foreach to the query function somehow and prevent a full query to the second table?

How can I select from multiple tables

$
0
0
How can I select from multiple tables using Query Builder?

Send 3 value on url (GET)

$
0
0
Sorry for english , there's a way to send and get 3 value on url in this way :

mydomain/index.php/my_controller/my_method/value1/value2/value3

How to create sitemap XML?

$
0
0
I have the store based website I want to create sitemap XML but I didn't know how to create please help?

Help to apply onion architecture in codeIgniter

$
0
0
I am new in codeIgniter I have read a book "The clean architecture in php" by Kristopher Wilson which says that If I apply the onion architecture, I will become more free in the dependency  of the framework.Also that book have a example with ZF2. How I can start to apply the onion architecture in codeIgniter?

Thanks

Community Auth - Login not valid after choosing other page after login

$
0
0
Hi all,

sorry to bother you again, but i probalby cannot see to wood for the trees.

I have implemented a login page that log's in my user (there is only one for now, level 9), the page is basically a copy of what is provided with the Community Auth package.

For the lack of a better page i get redirected to the login page after being logged in. The "real" pages and menu items will only appear after someone has logged in, so there is no page to start from (except maybe the landing page). This works fine, the menu is displayed, the username in the menu bar a.s.o.

But now if i navigate away from this page after being logged in all is gone, the variables ($auth_username and $auth_level) seem to get "lost.

The logfile says all is fine (https://pastebin.com/Ewdk0ju3). I can see the session cookies being created (btw. do they get purged automatically?).

I tried setting a different cookie name and domain (suggested in another post) but that did not help, quite the opposite a new session file was created for every click i made on the page, quite strange...

I only access the site from one machine using only one browser, i checked that the session library is not autoloaded.

Looks like i am running out of ideas where to look

Here is the entries in the "routes.php":
PHP Code:
$route['user/recover'] = 'User/recover';
$route['user'] = 'User';
$route['user/edit/(\d+)'] = 'User/update_user_view/$1';
$route['user/delete/(\d+)'] = 'User/delete_user/$1';
$route['user/add_view'] = 'User/add_user_view';
$route['user/logout'] = 'User/logout';
$route[LOGIN_PAGE] = 'User/login'

Any help is greatly appreciated, please let me know if i can provide any more information.

Thanks.
x

Google Analytics Integrate

$
0
0
Hello!

Does anyone have the experience of integrating the API Google Analytics in the CI4?

Use a set_rules callback in a libraries

$
0
0
Hello, 
I want to use a custom function to control an image field.
It works if I use it in the same controller with a callback ...

Exemple in my Administration Controller :


PHP Code:
if($config_rules['images'] == true){ $this->form_validation->set_rules('images','images','callback_require_upload');}

function 
require_upload(){ 

     
      $CI $this->CI =& get_instance(); 
     
      //$CI->load->model('question_model');

     
      $CI->form_validation->set_message('require_upload'"Vous devez uploader une image");
     
   return false;

    } 

It works.
The problem is that I want to put my validation rule in a Form_validation libraries like this:



PHP Code:
class MY_Form_validation extends CI_Form_validation

    protected 
$CI  
     
    function __construct
($config = array()){
 
         parent::__construct($config);
 
    }
        

    function 
require_upload(){ 
        
     
      $CI $this->CI =& get_instance(); 

     
      $CI->form_validation->set_message('require_upload'"Vous devez uploader une image");
     
   return false;

        
    }

 And I call now this rules like this : 


PHP Code:
if($config_rules['images'] == true){ $this->form_validation->set_rules('images','images','require_upload');} 

But I don't understand why it not works ?!

I need to help with routes problem.

$
0
0
I need to help with routes problem.

Below is a part of My Config/Routes.php file.

PHP Code:
$routes->setDefaultNamespace('MyTest\Controllers');
$routes->setDefaultController('Home');
$routes->setDefaultMethod('index');
$routes->setTranslateURIDashes(true);
$routes->set404Override('MyTest\Libraries\Errors::show404');
$routes->setAutoRoute(true); 

I need to use TranlateURIDashes. I hope that Router automatically route this.
for example, 'users/login-process' to 'users/login_process'.
but when I connect 'http://mytest/users/login-process', then just I could see 404 page not found error page.

So, Why? I don't understand this part..
Please, help me.

(Sorry, I'm not good at English..)

NPM event-stream


302 moved temporarily

$
0
0
Hi.

I have developed a web application and in local server works perfectly, but when I upload the application to a server on the internet (godaddy) I get this errors...

When I enter the data to enter the system in fractions of a second I get these errors and the page is reloaded

[Image: error1.jpg]

and when I repeat the same operation then I get this

[Image: error2.jpg]

This is my jquery
Code:
$(document).ready(function (){
$("#frm_login").submit(function (e){
   e.preventDefault();
   var url = $(this).attr('action');
   var method = $(this).attr('method');
    var data = $(this).serialize();
   $.ajax({
       url:url,
        type:method,
       data:data
   }).done(function(data){
       if(data !==''){window.location.href='Welcome/index';}else{alert('EL usuario y la contrasenna no coinciden');}
   });
});
});

This is my controller code (Welcome.php)
PHP Code:
<?php

if (!defined('BASEPATH'))
 
   exit('No direct script access allowed');

class 
Welcome extends CI_Controller {

 public function 
new_user() {
 
       $username $this->input->post('username');
 
       $password sha1($this->input->post('password'));
 
       $check_user $this->Usuarios->login($username$password);
 
       if ($check_user == TRUE) {
 
           $data = array(
 
               'is_logued_in' => TRUE,
 
               'id_usuario' => $check_user->id,
 
               'perfil' => $check_user->perfil,
 
               'username' => $check_user->user,
 
               'password' => $check_user->pass,
 
               'nombre' => $check_user->name
            
);
 
           $this->session->set_userdata($data);
 
           $this->index();
 
       } else {
 
           
        
}
 
   }

 
   public function index() {

 
       echo $this->session->userdata('perfil');
 
       switch ($this->session->userdata('perfil')) {
 
           case '':
 
               $layout_data['footer'] = $this->load->view('Footer'NULLTRUE);
 
               $layout_data['token'] = $this->token();
 
               $this->load->view('Welcome_message'$layout_data);
 
               break;
 
           case 'Administrator':
 
               redirect(base_url() . 'Admin');
 
               break;
 
           case 'Operator':
 
               redirect(base_url() . 'Suscriptor');
 
               break;
 
           default:
 
               $layout_data['footer'] = $this->load->view('Footer'NULLTRUE);
 
               $this->load->view('Welcome_message'$layout_data);
 
               break;
 
       }
 
   }



I hope somebody can help me.
THX!!!!

third locale detection

$
0
0
CI4 has 2 way of locale detection:

1. By url
Most modern websites use locale setting on some url part. But on complex url routing, this may not works (misinterpreted as segment or parameter instead of locale)

2. Content negotiation
Usually, browser has differ language than web. Some user wants to keep that. Also user may want to change language (force website for another language). So content negotiation cannot be used on this scenario.

I proposed 3rd way.

3. By Cookie.

My usecase:

My user can change website's language by clicking link which I put GET variable to that link. The new settings is saved on cookie.
When user visit, controller checks the cookie and GET variable,
- if both not present then using default locale
- if only one present, then that will be used
- if both present, then use setting from GET and change the cookie if differs from GET variable

Chronological order of data base on the date

$
0
0
Hello, we have a system used for our HR. One of the features is providing service records to our employees. We have already the data but the problem is when we retrieve and display those service records specially if the employee's service records reached 2 or 3 pages the last date showed on the first page will again show on the 2nd page. I hope your generous heart will able to help me. Thanks in advance

Note: If employee's service record is one page only we don't have problem.

I apologize, but Community Auth support must be put on hold.

$
0
0
15 plus years of typing and poor posture have caught up with me, and I physically cannot afford to help or develop Community Auth at this time. The good news is that it is mature, and with reading and searching you should do just fine.

Take care,
Brian

React Vs. Angular - Which one will win in 2019?

$
0
0
Suppose someone ask you for choose any one framework between angular and react, then which one you will choose?

Nowadays, React Vs. Angular is the trending topic. 

Can anbody tell me the right answer.
Viewing all 14148 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>