PHP Code Samples

Recent Tutorial

PHP Login with OTP Authentication

March 21, 2017
Login with an OTP code is a secure method for the user authentication process. In this method, a one-time password is generated dynamically and sent to the user who attempts login. OTP can be sent to the user’s email or his mobile phone. When the user enters the OTP code then the application will authenticate the […]
This tutorial was added to PHP.

Highlighting Keywords in Search Results with PHP

May 31, 2016
Highlighting keywords in search results will help a user to identify appropriate results easily. In a previous tutorial, we have seen advanced search in PHP. In this example, we are highlighting multiple keywords in search results. We are searching database title and description to check if the keyword has occurred. If match found we highlight those […]
This tutorial was added to PHP.

Advanced Search using PHP

May 30, 2016
In PHP advance search we have many options to filter MySQL data. Using these options we are creating database query condition to make an advanced search. In a previous tutorial, we have seen simple PHP search to filter MySQL records which have only one field to enter the search keyword. In the advanced search form, […]
This tutorial was added to PHP.

PHP Forgot Password Recover Code

March 23, 2016
In this post, we are going to see an example to learn how to recover the forgot password. In this example we have a forgot password form to get the username or email to recover the password. After form submits, we are sending password recovery email to the user. The Password recovery email has a […]
This tutorial was added to PHP.

PHP Login Script with Remember Me

March 23, 2016
In a login script, remember me feature is used to preserve the login name and password entered by the user. And it can be populated in the login form at the time of login. It minimizes the user effort by preventing to enter login details for each time. Some days before, we have seen PHP […]
This tutorial was added to PHP.

PHP MySQL Date Range Search with jQuery DatePicker

February 14, 2016
In this tutorial, we are going to see how to search database records date between two given ranges. It will return the filtered results from the database based on these dates input. In this tutorial, we are using jQuery DatePicker to choose the dates for the search options. These date inputs are used to form […]
This tutorial was added to PHP.

Show PHP Captcha on Failed Login Attempts

February 2, 2015
In this tutorial, we are going to show captcha code if a user tried more than 3 failed login attempts. In the previous tutorial, we have seen user login and PHP captcha. So, we are going to combine this two tutorial to add captcha control for invalid login. In this example, we have a MySQL […]
This tutorial was added to PHP.

User Login Session Timeout Logout in PHP

November 24, 2014
This PHP tutorial is used for setting user login session expiration time for the logged-in user. Once, this time is elapsed then the user no longer access the authenticated pages of the application. In the previous tutorial, we have created session variables once a user logged in to our application. In this tutorial, we are […]
This tutorial was added to PHP.

PHP CRUD with Search and Pagination

November 2, 2014
In this tutorial, we will see about a simple PHP application for database create, read, update and delete (CRUD) operations. With these CRUD operations, we will also have search and pagination features integrated to it. Earlier, we saw about CRUD with AJAX and CRUD without AJAX (both did not have search and pagination). Now in […]
This tutorial was added to PHP.

Command Line PHP

August 25, 2014
Using PHP though command line is possible and we will see how to do it in this tutorial. Generally, PHP is used for creating web-based applications. There are occasions where PHP script can be used apart from regular web applications such as automatic mail sending, Cron job for getting backup, automatic log tracking and etc. […]
This tutorial was added to PHP.

Send Email in PHP using Gmail SMTP

December 5, 2013
In this tutorial, let us see how to send email in PHP using PHPMailer library via Gmail SMTP. Sending email in PHP can be done with various mail transfer libraries available. For example,  PHPMailer, PEAR::Mail interface. These libraries provide advanced features like SMTP authentication and more. Sending an email with PHP’s core function mail() is […]
This tutorial was added to PHP.


October 18, 2013
cURL – Client URL library is used to communicate with different type of servers with protocols FTP, HTTP, telnet, gopher and more. In PHP, we have to install libcurl library for using cURL function. If we used any one of AMP bundle like XAMPP, to create PHP environment, then the cURL library will come up […]
This tutorial was added to PHP.

PHP Change Password Script

September 15, 2013
Change password feature in a web application is to let the user change their old password at some periodic interval. It makes the user protect the sensitive pages from hackers. Some web application fixes some expiration period for user’s password. It forces the user to change the password once the expiration period is elapsed. For […]
This tutorial was added to PHP.

PHP Login Script with Session

July 22, 2013
In this tutorial, let us see how we can implement authentication using a standard login form with session handling. Most of the website will have login script to provide user authentication. I will present you an example PHP code to implement authentication using a login script. With authentication, we can protect our website by filtering genuine […]
This tutorial was added to PHP.

PHP Mail

June 4, 2013
PHP provides mail() function for sending simple mail using PHP scripts. For that, the mail() function requires three arguments compulsorily and also two optional arguments, so totally five possible arguments as shown below. Recipient Email Address (Mandatory). Email Subject (Mandatory) Email Context or Message Body (Mandatory) Additional Header Information (Optional) Additional Parameters (Optional) First three […]
This tutorial was added to PHP.

↑ Back to Top