How to Send AJAX request with CSRF token in CodeIgniter 4

Cross-Site Request Forgery (CSRF) requests are a type of malicious exploit whereby unauthorized commands are performed on behalf of an authenticated user.

CodeIgniter 4 provides protection from CSRF attacks. But it is not enabled by default same as CodeIgniter 3.

The token is generated for each user and it is managed by CodeIgniter to verify the user request.

In this tutorial, I show how you can enable CSRF protection and send AJAX request with CSRF token in the CodeIgniter 4 project.

How to Send AJAX request with CSRF token in CodeIgniter 4

Read more

Edit Delete DataTables record with AJAX and PHP

With the use of the DataTables jQuery plugin, you can list your records in pagination format.

You can add HTML elements like – buttons, link, image, etc with a record.

For this need to pass element in HTML string format from the PHP script.

In this tutorial, I show how you can add edit and delete buttons in the Datatables AJAX pagination with PHP.

NOTE – I am using the Bootstrap modal to update a record.

Edit delete DataTables record with AJAX and PHP

Read more

Datatables AJAX pagination with Search and Sort – Laravel 7

DataTables is a jQuery library that is used to create pagination. It comes with various features – pagination, sorting, search, etc.

You can load data with and without AJAX.

In this tutorial, I show how you can create AJAX pagination with search and sort using DataTables in Laravel 7.

I am not using Laravel package for DataTables.

Datatables AJAX pagination with Search and Sort - Laravel 7

Read more

How to Export MySQL data to CSV by Date range with PHP

CSV file is been used for data import, export, and generating a report.

If you have huge data available in the MySQL database and you only require a specific date range data but the file contains all records and you need it on your own.

By adding a date filter to the form you just need to pick the range and export it.

In this tutorial, I show how you can export MySQL database data in CSV format by date range with PHP. I am using jQuery UI for datepicker.

How to Export MySQL data to CSV by Date range with PHP

Read more