⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠


profile picture

Something went wrong! 403 error


  • profile picture
  • Member

Posted 03 March 2020 - 23:17 PM

I created the controller in codeigniter but when I load the page I keep getting a 403 error and nothing from the database will populate. I have attached a picture. 




  • profile picture
  • Member

Posted 03 March 2020 - 23:25 PM

My Controller Code:

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

// Add those two lines at the beginning of your controller
include(APPPATH . 'libraries/GroceryCrudEnterprise/autoload.php');
use GroceryCrud\Core\GroceryCrud;

class User extends BackendController
	private function _getDbData() {
		$db = [];
		include(APPPATH . 'config/database.php');
		return [
			'adapter' => [
				'driver' => 'mysqli',
				'host'     => $db['default']['hostname'],
				'database' => $db['default']['database'],
				'username' => $db['default']['username'],
				'password' => $db['default']['password'],
				'charset' => 'utf8'
	private function _getGroceryCrudEnterprise($bootstrap = true, $jquery = true) {
		$db = $this->_getDbData();
		$config = include(APPPATH . 'config/gcrud-enterprise.php');
		$groceryCrud = new GroceryCrud($config, $db);
		return $groceryCrud;

	public function index()
		$crud = $this->_getGroceryCrudEnterprise();
		$crud->setSubject('User', 'Users');
		$crud->columns(['first_name','last_name','email','phone', 'active', 'groups']);
		$crud->setRelationNtoN('groups', 'user_groups', 'groups', 'user_id', 'group_id', 'name');

		$output = $crud->render();

	function _example_output($output = null) {
		if (isset($output->isJSONResponse) && $output->isJSONResponse) {
			header('Content-Type: application/json; charset=utf-8');
			echo $output->output;


My View code:

<!DOCTYPE html>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    foreach($css_files as $file): ?>
        <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
    <?php endforeach; ?>

<div style="padding: 20px 10px;">
    <?php echo $output; ?>
<?php foreach($js_files as $file): ?>
    <script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>


  • profile picture
  • Member

Posted 04 March 2020 - 06:19 AM

Hi kevbo75217, 


Try inputting the actual values of the  host, database, username, password first just to test if it works.

I hope this helps...  :)


  • profile picture
  • Member

Posted 04 March 2020 - 09:15 AM

Thank you for responding larasmith,


The error wasn't related to Grocery Crud. It was from a template library that I installed ci-simplicity. They were both using the same variable for the output buffer. I had to remove it in order to get grocery crud to work. Love the library though.