Login-GroceryCrud icon indicating copy to clipboard operation
Login-GroceryCrud copied to clipboard

Detailed instruction

Open udz99 opened this issue 5 years ago • 6 comments

using enterprise edition of GC

folow the tutz, where is the line to enter database (username & password) to create 'crud_users'

can i get your script on grocerycrud.php ? if there a video tut that would be wonderful...

thanks

udz99 avatar Aug 02 '19 16:08 udz99

Hi,

This is the instructions on how to do it: https://github.com/portapipe/Login-GroceryCrud/blob/master/README.md#how-it-works

portapipe avatar Aug 02 '19 19:08 portapipe

ok.. i drag 3 file to my project which is : login.php (controller) login_model.php (model) login.php (view)

im using default database which is "customers" table $crud->setTable('customers');

my Examples.php

'<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); include(APPPATH . 'libraries/GroceryCrudEnterprise/autoload.php'); use GroceryCrud\Core\GroceryCrud; class Examples extends CI_Controller {

public function __construct()
{
	parent::__construct();

	$this->load->database();
	$this->load->helper('url');

	// You can simply remove these lines once you have base_url installed correctly
	$config = [];
	include(APPPATH . 'config/config.php');
	if ($config['base_url'] === '') {
		show_error('You forgot to add the $config[\'base_url\'] at application/config/config.php . For more check the video tutorial here: <a href="https://youtu.be/X0gnDD0qTS8?t=24s" target="_blank">Common mistakes when we install Grocery CRUD</a>');
	}
}

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

	$this->load->view('example.php',(array)$output);
}

public function index()
{
	$this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
}

public function customers_management()
{
	$crud = $this->_getGroceryCrudEnterprise();

	$crud->setTable('customers');
	$crud->setSubject('Customer', 'Customers');

	
	if($this->login_model->isLogged()){
		$name = $this->login_model->name();
		echo "HI $name! You are Logged IN!";
	}else{
		redirect("/login");
	}

	$output = $crud->render();

	$this->_example_output($output);
}

private function _getDbData() {
    $db = [];
    include(APPPATH . 'config/database.php');
    return [
        'adapter' => [
            'driver' => 'Pdo_Mysql',
            '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-enteprise.php');
        $groceryCrud = new GroceryCrud($config, $db);
        return $groceryCrud;
}

i got this image

when i click create database which is will create a table name "crud_users" image

so i create manually on my table and name it "crud_users"

image

then i got login page

image

insert username : admin password : admin

i got this image

any clue....???

udz99 avatar Aug 03 '19 12:08 udz99

For some reason there is no index.php in the url. Try use htaccess to remove index.php from your urls or just add index.php to the non function pages

portapipe avatar Aug 03 '19 12:08 portapipe

will try again asap

did my example.php is corect ?

public function customers_management() { $crud = $this->_getGroceryCrudEnterprise();

$crud->setTable('customers');
$crud->setSubject('Customer', 'Customers');


if($this->login_model->isLogged()){
	$name = $this->login_model->name();
	echo "HI $name! You are Logged IN!";
}else{
	redirect("/login");
}

$output = $crud->render();

$this->_example_output($output);

}

also why i cannot make automagicaly this image

where is the line to set db connection for this ?

udz99 avatar Aug 03 '19 14:08 udz99

Fix the stuff I told you. I don’t use enterprise edition at the moment, so I don’t know if your example need something else but it seems fine

portapipe avatar Aug 03 '19 19:08 portapipe

I solved this:

Changing in vienes/ login.php

Replace

To

<form class="form col-md-12 center-block" action="<?php echo site_url('login/makeLogin')?>" method="post">

effectively is missing "index.php" in url, this add "index.php" without modify ".htaccess"

cahedral avatar Apr 03 '20 07:04 cahedral