Switch PHP Versions on Ubuntu | How can I downgrade from PHP 7 to PHP 5.6 on Ubuntu 16.04? | How to install PHP on Ubuntu?

We often work on multiple projects and there might be possibility the you are working on a project which has been developed in latest PHP version and another project has been developed in older PHP version.

I faced the same challenge in my projects and here in this article I'll explain the installation of PHP version 7.0 and 5.6.

We also will be upgrading and downgrading PHP versions. We will not uninstall and PHP version we will keep both versions of PHP but we will switch PHP version according to our need. ...  Read More

Share This:


Securely Hash Passwords with PHP | How to work with users' passwords and how to securely hash passwords in PHP?

Hashing passwords with md5 (or sha1, or even sha256) is not safe anymore, because these hashes can be decrypted very easily.This is still not good enough though (rainbow tables). PHP 5.5+ came with a password_hash function to generate secure, one-way hashing along with a password_verify function to match a hashed password with the given password. For a developer security is always a priority so you should always be securely storing user passwords. We has passwords due to security concern and information leakage concern. If we store passwords in plain text then it can be compromised of information very easily. ...  Read More

Share This:


Simple Shopping Cart in PHP & MySQL | PHP code for Shopping Cart

Shopping Cart Example PHP

Shopping Cart Example PHP

There are many e-commerce application and we are still building e-commerce application but all of them has common functionality and the functionality is shopping cart.

We are here to learn, How to build a simple shopping cart in PHP and MySQL? In this article I'll be creating a very simple cart system where you will be able to add the products into the cart and can remove the products from the cart. You also will be able to empty cart or remove all products from the cart.


Here are the MySQL queries:

I'll be using session to add or remove the products from the cart. First of all I'm fetching products from MySQL and listing all the products on the web page.
Create a new PHP file like:
index.php

Here is the simple products listing. I also have add to cart button here and a text field to enter the quantity. I also have used connection file here which creates a connection with MySQL using PHP...  Read More

Share This:


Live Email Availability Checking using PHP, jQuery and Ajax

Often in registration form we need a a feature to check the live availability of user. Obviously it is worth that after submitting all the details to tell the user that user already registered. It's better approach to tell the user while filling the form.

email-id-available
In this article, we will see a live check availability of email id by using AJAX, jQuery, and MySQL.
You will require to enter the email id and you will be able to check weather the email id already exist or not while typing the email id.



Here is the HTML and jQuery part. ...  Read More

Share This:


Server side DataTable in PHP,MySQL and Ajax | DataTable in PHP and MySQL | DataTables Example - Server-side Processing with PHP | DataTables example - Server-side processing | Add column in DataTable in PHP

Server side DataTable Example

Server side DataTable Example

We often display data in tables. We do pagination, searching and sorting manually on those tables. DataTables is the beautiful concept for doing all these things you can say your food is ready to eat. You just need to use some peace of code and you can display data in tables with beautiful features like Pagination, Searching and Sorting.

We will display data in chunks so that this will be easy for MySQL to serve the data. It'll also increase your performance You can change your pagination limit as well for example if you wanted to display 25 records on every page you can do that very easily.


 ...  Read More

Share This:


Import csv in PHP | How to import csv file in PHP? | How to Import CSV File Data into MySQL Database using PHP | Import a CSV File Using PHP and MySQL | How To Import CSV File Into MySQL Using PHP? | How to Import CSV Into MySQL Database Using PHP | Import CSV data into MYSQL using PHP

import-csv-php-mysql

Import CSV in PHP & MySQL example

In most of the PHP web applications we stores data into MySQL database. We also export data in PHP or import data in PHP.

Here in this article I'm explaining how you can achieve the task of import CSV (comma-separated values)  into MySQL database with PHP.

In most of the projects uploading data or reports is a common task which we do so this article is very important for you to learn storing the CSV file data into MySQL.

A CSV file stores data in tabular format that can be separated by either comma(,) or semicolon(;). So this is very easy to read every row and insert all the rows into MySQL database. ...  Read More

Share This:


Export To Excel with Headers In PHP and MySQL | How to Export MySQL Data in Excel/CSV File using PHP/MySQL

export to excel from mysql in php

Export MySql data to Excel example

So many time we need to export data from MySql to Excel or CSV. So many time we need to send reports in excel and we require to export data from MySql to Excel.

We can perform this task very easily in PHP. Here in this article I'm going to explain how we can export the MySql data into excel or CSV in PHP.

I will be writing single PHP script which will work for excel and CSV both. We can do it by just changing the headers of file.



 ...  Read More

Share This:


Add Remove input fields dynamically using jQuery and PHP

add-more-field

Add/Remove field example in JQuery and PHP

Sometime we need to add or remove fields dynamically in a form.
In this article I'm explaining that how can we add or remove the fields using jQuery.
We just need to click on Add more button and a new field will be added. You also can remove that field.
In this article I also have written the code for inserting the data into MySql.

Here I'm giving an example of tags.

Like If we have requirement of add more tags. And we want to add tags as much as we want. You can do that easily by using this code.
You also can insert all the tags into the MySql database using PHP...  Read More

Share This:


Function return type in PHP 7 and void return type in PHP 7.1

One of the beautifull feature of programming languages came out in PHP 7 that now we also can have function return type in PHP like we have in other languages like Java, C, C# etc..
So PHP 7 adds support for return type declarations.
Now we can force a function to return a specific type of data.



In PHP 7 we have following function return types:
int : Integer data type.

float : Float data type.

array : Array data type.

bool : Boolean data type.

string: String data type.

Class/Interface name : Name of the class.

self : Instance of the same class. This can only be used if function is created under any class.

callable : Valid PHP callable.

 ...  Read More

Share This:


Can we run a PHP file without a server or without a browser?

One word answer to this question is simply YES.

PHP is just a scripting language like others. Most of the people when hear about PHP, they think of websites first. But it can serve many other purpose. Of course it is actively and primarily being used for web development.

PHP is a server side scripting language, which means it runs on a server ( more precisely a web server). However one can write programs in PHP without having a web server at all.

Yes, by installing a CLI application you can print out the response in the terminal. ...  Read More

Share This: