Login-GroceryCrud
Login-GroceryCrud copied to clipboard
Detailed instruction
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
Hi,
This is the instructions on how to do it: https://github.com/portapipe/Login-GroceryCrud/blob/master/README.md#how-it-works
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
when i click create database which is will create a table name "crud_users"
so i create manually on my table and name it "crud_users"
then i got login page
insert username : admin password : admin
i got this
any clue....???
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
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
where is the line to set db connection for this ?
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
I solved this:
Changing in vienes/ login.php
Replace