Introduction to Inheritance in PHP

Inheritance is one of the basic concepts of object-oriented programing methodology. It allows a class to “inherit” the properties and methods of an existing class by extending it. Unless the child class “overrides” the methods of the existing class, they will maintain their original functionality. The relationship between these classes is called a parent-child relationship.... » read more

Introduction to DNS lookup function in PHP

In this example, you will learn about the DNS look function in PHP and how to use it. For demonstration purpose, we will create a simple HTML form which takes domain name from as the user input. The form will be submitted to practice_ac.php which contains the PHP code to lookup the DNS record of the domain... » read more

An Introduction to Arrays in PHP

In any programming language, a variable is a memory location that holds a value. It could be a number, string, an object but at a time, it can contain only one value. What if you need 20 such values, or 50 or even 100? One way is to declare and initialize those 100 variables. The... » read more

Preventing Multiple Submissions on the Server Side using PHP

The code below will help you to prevent multiple form submission from the users using PHP. First, create a web form as shown below. <?php session_start (); ?> <!DOCTYPE html> <html> <head> <link href="" rel="stylesheet"> <style> *{box-sizing:border-box;} body{font-family: 'Open Sans', sans-serif; color:#333; font-size:14px; background-color:#dadada; padding:100px;} input{padding:5px; margin-bottom:5px; width:300px;} </style> <body> <?php if(isset($_POST['submit'])){ if (!isset (... » read more

How to create a multi-page form in PHP

When creating a multi-page form, you can save the data being entered at every step in session variables or temporary database. In this tutorial, we will be creating three different pages to save the information being entered in the session variables. Multi-page Form in PHP To get started, create a web form as shown below <?php... » read more

How to create a Bar Chart using PHP

To create bar chart using PHP, you can use the built-in function Imagefilledrectangle() which draw a rectangle according the given x and y coordinates. The Syntax imagefilledrectangle ( resource $image , int $x1 , int $y1 , int $x2 , int $y2 , int $color ) : bool The Parameters $x1, $y1 set the top... » read more

How to draw a Pie chart using PHP

Creating an image using PHP may seem like a daunting task, but it is straightforward if you know what are you trying to draw using PHP’s GD library for images. Pie Charts in PHP To create a pie chart in PHP, create a new file piechart.php as shown below. <?php $image_width = 400; $image_height = 400;... » read more

Use Cookies to Create Page Counter in PHP

In this tutorial, we are going to learn to create a simple cookie-based visitor counter. This counter will start from zero and will be incremented for each visit. For the sake of testing the code, the counter will reset after you close the browser. setcookie() defines a cookie to be sent along the rest of... » read more

Global Variable $_SERVER Explained in PHP

$_SERVER is an array containing information about server and execution environments. The array has values for headers, paths and script locations. The values are created by the web server. Let’s go through the $_SERVER array. You can see the complete list of variables in the array using the following code. List of Complete Global $_SERVER... » read more

Create a Time Sensitive Form in PHP

A time-sensitive form lets you enter and submit the information within the time limit being specified. In this tutorial, we will create a simple form that allows you to enter your name within 5 minutes of form being loaded. If you failed to do so, it would show an error message that you are too... » read more

Understand the File Upload Error Constants in PHP

Uploading files or images can be a crucial part of any web application. Let’s say you ask a user to upload his picture in jpeg or png format. So how you are going to check if the file is being uploaded successfully? What if the file was uploaded partially due to some network problem? PHP... » read more

Get vs. Post in PHP with Examples

The GET and POST are the two highly used methods in web applications where users submit information over the website. HTML forms usually have some input fields to extract valuable information from the visitors. Either you want to send this information to any other page, or database you need to specify a method which defines... » read more

Create a Feedback form using PHP

A Feedback form can be the most convenient way to understand how users feel about your products or services. The feedback or suggestion given by the end user can be of real help to improve your outcomes or the overall process. A simple feedback form in PHP Firstly, you create an HTML form to get the... » read more

Validating the checkbox in PHP

If the checkbox is checked, then the value of checkbox will be passed on the submission of the form. Otherwise, the value is empty. You can validate the value of a checkbox only after the form is being submitted. For example: <input type='checkbox' name='accept' value='1' id='checkbox' /> I accept the Terms & Conditions. Use the... » read more

Create a Login Page Using PHP and MySQL

In this tutorial, we will learn how to create a simple authentication form using PHP and MySQL. This tutorial covers the fundamental concept of sessions and query execution. How to Create a Login Page Using PHP and MySQL I’m sure you have seen those simple login forms with user name and password that let you access... » read more