Welcome, Guest
You have to register before you can post on our site.



Search Forums

(Advanced Search)

Forum Statistics
» Members: 23,981
» Latest member: yummycakes
» Forum threads: 73,325
» Forum posts: 375,149

Full Statistics

Latest Threads
Query Builder need help
Forum: CodeIgniter 4 Discussion
25 minutes ago
» Replies: 5   » Views: 135
Which browser do you guys...
Forum: Lounge
50 minutes ago
» Replies: 81   » Views: 55,082
valid_date not working as...
Forum: CodeIgniter 4 Support
2 hours ago
» Replies: 0   » Views: 21
how set CI_ENV for codeig...
Forum: General Help
6 hours ago
» Replies: 6   » Views: 2,845
I am currently using Code...
Forum: General Help
7 hours ago
» Replies: 2   » Views: 92
Codeigniter-4 not working...
Forum: Installation & Setup
7 hours ago
» Replies: 1   » Views: 63
How to load a model in Au...
Forum: CodeIgniter 4 Support
8 hours ago
» Replies: 7   » Views: 212
CodeIgniter.com - Report ...
Forum: News & Discussion
Yesterday, 10:07 PM
» Replies: 50   » Views: 28,251
website is getting blank ...
Forum: CodeIgniter 4 Support
Yesterday, 09:15 PM
» Replies: 5   » Views: 172
Code Igniter is the best ...
Forum: Choosing CodeIgniter
Yesterday, 08:48 PM
» Replies: 30   » Views: 24,541

  valid_date not working as expected
Posted by: sfarzoso - 2 hours ago - Forum: CodeIgniter 4 Support - No Replies

I'm trying to validate this date: 14/04/2021 16:00, so inside the validation rules of the controller I did:

PHP Code:
        $validationRules = [
            'title'             => 'required|min_length[1]|max_length[60]',
            'author_id'         => 'required|integer',
            'status'            => 'required|in_list[draft,published]',
            'published_date'    => 'required|valid_date[d/m/Y H:m"]'

the problem's that when the code reach this line:

PHP Code:
if (!$this->validate($validationRules)) {
      var_dump(date("d/m/Y H:m"));
      return redirect()->back()->withInput()->with('error'$this->validator->getErrors());

The field published_date must contains a valid date

  Codeigniter-4 not working on VPS Server
Posted by: Ismail Agha - Yesterday, 09:48 PM - Forum: Installation & Setup - Replies (1)

Hello Team,

The CI code/website is working fine for me on the localhost. But it's failing when migrated to the live server. 

The code is failing after reaching to below lines of code in the file ' system/bootstrap.php ':
$appConfig = config(\Config\App::class);
$app      = new \CodeIgniter\CodeIgniter($appConfig);

The call to bootstrap.php is made in the index.php page :
$app = require rtrim($paths->systemDirectory, '/ ') . '/bootstrap.php';

Could someone please help me to solve this issue?

Thanks & Regards

  Need help on converting mysql query to codeigniter active record
Posted by: jollytsr - Yesterday, 03:59 AM - Forum: CodeIgniter 3.x - Replies (1)

SELECT date(`timestamp`)
     , COUNT(`odr_id`) AS num_sales
     , SUM(`amnt_paid`) AS daily_total
     , SUM(gov_fee) as e_pay
     , SUM(items_total) as sum_tot_cost
  FROM item_table
    BY date(`timestamp`)
where ('user', $this->session->userdata('usernm'));

I get the username as table column and throws error saying "column not found"

  I am currently using Codeigniter 4.1.1 how do you retrieve data from the $afterInsert
Posted by: John mark bartholomon - 04-12-2021, 10:12 PM - Forum: General Help - Replies (2)

I am currently using Codeigniter 4.1.1 how do you retrieve the returned data from the $afterInsert callback here are my codes
my question is how to get retrive and access the returned $data from the model inside my controller (I am fairly new to codigniter any help will be appreciated)

    public function newBlog(){

        if($this->request->getMethod() == 'post'){
            $model= new SampleBlogModel();

        echo view('SampleBlogView');

class SampleBlogModel extends Model{
    protected $table = 'testdata';
    protected $allowedFields = ['blogContent' , 'blogTitle'];
    protected $primaryKey = 'blogId';

    protected $afterInsert = ['checkName'];

    protected function checkName(array $data){
        return $data;



  One .env File for Development and Production
Posted by: rajsubhag - 04-12-2021, 08:08 PM - Forum: CodeIgniter 4 Support - No Replies

Hi There,

I have been using CI for years now and now trying my hands on CI4. It has a cool feature where environment variable can be set with .env file.

How can I use one env file for staging and production. I want the ability to change the environment and CI will pick up the relevant variables.

For example:



When the environment is changed, CI to pick up the respective credentials.

Please advise if this can be achieved in CI4


  CodeIgniter 3 - 403 Forbidden on POST from jQuery.ajax() asynchronous request
Posted by: josephgodwinke - 04-12-2021, 02:53 PM - Forum: General Help - No Replies

I am getting a 403 forbidden error on jQuery.ajax() post request.

$config['csrf_protection'] = TRUE;
$config['csrf_token_name'] = 'csrf_ghive';
$config['csrf_cookie_name'] = 'csrf_ghive';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = false;
<input type="text" class="txt_csrfname" name="<?= $this->security->get_csrf_token_name(); ?>" value="<?= $this->security->get_csrf_hash(); ?>">

<button id="bill_client"><?php echo lang('pay'); ?></button>

<script type="text/javascript" src="<?php echo base_url(); ?>assets/customers/js/bill.js"></script>


function add_bill_by_ajax(bill_object,bill_id){
    // CSRF Hash
    var csrfName = $('.txt_csrfname').attr('name'); // Value specified in $config['csrf_token_name']
    var csrfHash = $('.txt_csrfname').val(); // CSRF hash
            order : bill_object,
            sale_id : bill_id,
            close_order : 0,
            //csrf_test_name: $.cookie('csrf_ghive')
            //'<?php echo $this->security->get_csrf_token_name(); ?>':'<?php echo $this->security->get_csrf_hash(); ?>'
           [csrfName]: csrfHash
        dataType: 'json',
        success:function(response) {
                     title: warning,                                                                                      
                     text:  added_bill,                                                                                      

                console.log("403 Forbidden for ajax error");
                       title: warning,                                                                                      
                       text:'403 Forbidden for ajax error',                                                                                      
                       allowOutsideClick: false                                                                                   


  function add_bill_by_ajax(){
        $bill_details = json_decode(json_decode($this->input->post($this->security->xss_clean('bill'))));      
        //this id will be 0 when there is new bill, but will be greater then 0 when there is modification
        //on previous order
        $bill_id = $this->input->post('bill_id');
        $close_bill = $this->input->post('close_bill');     
        $data = array();
        $data['token'] = $this->security->get_csrf_hash();
        $data['customer_id'] = trim($bill_details->customer_id);  

Browser Console errors

jquery-3.3.1.min.js:2 POST http://localhost/Bill/add_bill_by_ajax 403 (Forbidden)
send @ jquery-3.3.1.min.js:2
ajax @ jquery-3.3.1.min.js:2
add_bill_by_ajax @ custom.js:3764
(anonymous) @ bill.js:2362
dispatch @ jquery-3.3.1.min.js:2
y.handle @ jquery-3.3.1.min.js:2

Browser Network errors

bill: "{\"customer_id\":\"1\",\"product_price_with_discount\":\"5000.00\",\"product_discount_amount\":\"0.00\",\"product_note\":\"\"}]}"

bill_id: 0
close_bill: 0
csrf_ghive: 6555e8953c1aee584cf2472c1ad14a4d

  .htaccess on an https server
Posted by: goobydale - 04-12-2021, 11:14 AM - Forum: General Help - Replies (1)

I am using codeigniter 3.1.11 for a school project. Locally, I have set-up this .htacces file

<IfModule mod_rewrite.c>
# deny from all
RewriteEngine On

RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d

RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

With these settings :

PHP Code:
$config['base_url'] = 'http://localhost/codeigniter';

$config['index_page'] = '';

$config['uri_protocol']    = 'REQUEST_URI'
Locally, the rules work (i.e: localhost/codeigniter/welcome) takes me to the welcome page.

However, these same rules, do not work on the student server provided by my school.
Even after I have adapted everything, I still need to put index.php in the URL

PHP Code:
$config['base_url'] = 'https://'.$_SERVER['SERVER_NAME'].'/codeigniter'

If i try to access the welcome controller the same way I did locally, I only get back
File not found.

on the browser.

The servername follows this logic : studentNumber.SCHOOL_SERVER.com (connected via school vpn)

Any ideas?

  40+ Useful Resources for Mastering Web
Posted by: php_rocs - 04-12-2021, 07:09 AM - Forum: Lounge - Replies (1)

I came across this useful resource article and decided to share it with the CI community.


Posted by: shanumathur001 - 04-12-2021, 03:09 AM - Forum: Jobs - No Replies

We are looking a person to add some more item to this page:

URL: rajasthanbhumitours.com/Golden-Triangle-Tour-Packages.php

  Query Builder need help
Posted by: zdarin - 04-12-2021, 02:57 AM - Forum: CodeIgniter 4 Discussion - Replies (5)


i cant understand how pass data from controller to model query builder for example
i want get one contact card view by query builder where('id', $findid) how pass $findid variable?
or i should this done in controller?

and second question this below as example written is query builder example or not? If yes why no connection to DB and its working?

PHP Code:
    public function getNews($id false)
        if ($id === false)
            return $this->findAll();

        return $this->asArray()

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.