How to upload a file using jQuery AJAX in CodeIgniter 4

With AJAX you can perform an action on the server without refreshing the whole page.

You can use it to fetch data, import file data, upload files, etc.

In this tutorial, I am using it to upload a file and display a preview if the file is an image otherwise display a link in the CodeIgniter 4 project.

I have enabled CSRF token in the CodeIgniter project.

How to upload a file using jQuery AJAX in CodeIgniter 4

Read more

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 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