Posts

Showing posts from September, 2022

Webservices in PHP (How to create user registration/signup Webservice)

Image
  What is Webservices? Webservices are used to allow users to access data from different sources like the Android app, IOS app, website etc from a centralized database. We can create a web service through two methods : SOAP (Simple Object Access Protocol) REST (Representational State Transfer) SOAP (Simple Object Access Protocol) SOAP : Simple Object Access Protocol. SOAP is easy to read because SOAP based on XML. SOAP is the XML based format  for sending and receiving data. REST (Representational State Transfer) REST : Representational State Transfer. It is an architectural style that run over HTTP. REST webservices generate status code response in JSON & XML. REST support all HTTP methods GET, POST, PUT & DELETE. GET :  Retrieve particular resources by an id POST :   Create a new resource. PUT :  Update a  particular resource by an id. DELETE :  Remove a particular  resource. Click : https://phpgurukul.com/webservices-in-php/ Example of POST  Step 1 :  Create a database ( cr

CRUD operation using PHP and MySQLi | PHP Gurukul

Image
 In this tutorial, we will learn how to create CRUD operation using PHP and MySQLi . CRUD Stands for create, read, update and delete record in the database. Files includes in this tutorials phpcrud.sql:  Contain the database table structure. dbconnection.php:  Used for database connection. index.php : Used to fetch the record from database. read.php:  Used to fetch the record of particular user. edit.php:  Used to edit the record. insert.php:  Used to insert the new record. Step 1– Create a database Open browser type http://localhost/phpmyadmin, create a database named ‘phpcrud’. After creating database run the SQL script or import the SQL file. MySQL Table tblusers structure CREATE TABLE `tblusers` ( `ID` int(10) NOT NULL, `FirstName` varchar(200) DEFAULT NULL, `LastName` varchar(200) DEFAULT NULL, `MobileNumber` bigint(10) DEFAULT NULL, `Email` varchar(200) DEFAULT NULL, `Address` mediumtext DEFAULT NULL, `CreationDate` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current

Interfaces – the next level of abstraction

Image
  Interfaces resemble  abstract classes  in that they include abstract methods that the programmer must define in the classes that inherit from the interface. In this way, interfaces contribute to code organization because they commit the child classes to the methods that they should implement. The use of interfaces become very helpful when we work in a team of programmers and want to ensure that all the programmers write the methods that they should work on, or even in the case of a single programmer that wants to commit himself to write certain methods in the child classes. An interface commits its child classes to abstract methods that they should implement. How to declare and implement an interface? We declare an interface with the interface keyword and, the class that inherits from an interface with the implements keyword. Let’s see the general case:   1 2 3 4 5 6 7 interface interfaceName { // Abstract methods } class Child implements interfaceName { // Defines the interfac

Polymorphism in PHP

Image
  In this tutorial, we are going to learn a naming convention that can help us write code which is much more coherent and easy to use. According to the Polymorphism (Greek for “many forms”) principle, methods in different classes that do similar things should have the same name. According to the Polymorphism principle, methods in different classes that do similar things should have the same name. Click : https://phpgurukul.com/polymorphism-in-php/ A prime example is of classes that represent geometric shapes (such as rectangles, circles and octagons) that are different from each other in the number of ribs and in the formula that calculates their area, but they all have in common an area that needs to be calculated. In such case, the polymorphism principle says that all the methods that calculate the area (and it doesn’t matter for which shape or class) should have the same name. For example, we can write in each class that represents a shape a calcArea() method that calculates the are

Static methods and properties | PHP Gurukul

Image
  We can access static methods and properties without the need to first create an object, but their use should be limited. We have already learned about the three access modifiers called  public , protected and  private . This chapter is devoted to the fourth modifier, static, that allows access to classes’ properties and methods without the need to create objects out of the classes.  How to define methods and properties as static?  In order to define methods and properties as static, we use the reserved keyword static. In the following example, the class Utilis has a static public property with the name of $numCars, and so the property’s name is preceded by both the static as well as the public keywords. Click : https://phpgurukul.com/static-methods-and-properties-2/   1 2 3 4 5 class Utilis { // Static methods and properties // are defined with the static keyword static public $ numCars = 0 ; } How to approach static methods and properties? In order to approach static methods a

What are exceptions and how to handle them?

Image
 Exception handling is an elegant way to handle errors which are beyond the program’s scope. Click : https://phpgurukul.com/what-are-exceptions-and-how-to-handle-them/ In this tutorial, we are going to learn how and when to use exception handling and, even more important, when not to use it. In order to explain the need for exception handling, we will try to see what happens when a program is fed with faulty data. In our example, we will develop the class FuelEconomy that calculates with the method calculate() the fuel efficiency of cars by dividing the distance traveled by the gas consumption. class FuelEconomy { // Calculate the fuel efficiency public function calculate ( $ distance , $ gas ) { return $ distance / $ gas ; } } We will feed the class with the nested array $dataFromCars, in which each nested array has two values: the first value is for the distance traveled and the second value is for the gas consumption. While the first and last nested arrays contain legitimate d

Learn How to Develop Object Oriented Programming Concepts in PHP

Image
  Learn How to Develop Object Oriented Programming Concepts in PHP Centered around the concept of manipulating objects by identification, also known as modeling, is what OOP is all about. The identification and relation of objects to each other is what the programmer attempts. This novel concept of programming is a lot different from logic based programming. Let us dive through the codes to get a better understanding of OOP and how the concepts can be used in PHP. Classification of data OOP defines classes of data and sub classes.  This reduces the time required for development, in addition to helping in accurate coding. By virtue of the extensive analysis of the data, known as inheritance this characteristic of OOP sets it apart. OOP prevents data corruption.  As a result of the classification, the codes will never be able to access data that is unconnected. Known as data hiding, this typical characteristic of OOP lends it greater security. OOP permits programmers to create or define

OOPs Concept in Php – Offering A Smarter Future for Users | PHP Gurukul

Image
All the programmers of the world know how efficient PHP is when it comes down to web development. Offering simplicity with the same advanced features, PHP has won the hearts of beginners and professional programmers alike. The innovations have, however, continued, and have resulted in OOP (Object Oriented Programming) technique in PHP – a convenience that no other combination can manage. In this blog you shall learn about how OOPs concepts in PHP are offering a smarter future for users. Click :  https://phpgurukul.com/oops-concept-php-offering-smarter-future-users/ First, let us understand a little about OOPs.  Object Oriented Programming , as the name calls out, is related to defining real time objects to run a code instead of straight forward logic. It works as what one would refer to as a “Data bank”. This allows the programmers to build classes into a code which makes it easier to manage. Benefit #1: Anyone can use the file In places where a coding goes through the hands of many p

User Registration and Login using PHP Oops Concepts | PHP Gurukul

Image
  In this tutorial we will learn how user can register and login using PHP Oops concepts. File Structure for this tutorial : index.php (User Registration form) sigin.php (User signin form) function.php (Database connection and function for username availability, registration, and login) welcome.php (After login user will redirect to this page) logout.php (for logout) MySQL table tblusers structure used in this tutorial   1 2 3 4 5 6 7 8 CREATE TABLE ` tblusers ` (    ` id ` int ( 11 ) NOT NULL ,    ` FullName ` varchar ( 120 ) DEFAULT NULL ,    ` Username ` varchar ( 120 ) DEFAULT NULL ,    ` UserEmail ` varchar ( 200 ) DEFAULT NULL ,    ` Password ` varchar ( 250 ) DEFAULT NULL ,    ` RegDate ` timestamp NULL DEFAULT CURRENT _ TIMESTAMP ) ENGINE = InnoDB DEFAULT CHARSET = latin1 ; Now creates a function.php. In this file class Class DB_con, Inside this class define the database connection.Now inside this create your function for username availability, user regist

Garbage Management System using PHP and MySQL

Image
The world is in a stage of upgradation, there is one stinking problem we have to deal with. Garbage! In our daily life, we see pictures of garbage bins being overfull and all the garbage spills out. This leads to the number of diseases and insects and mosquitoes breed on it. A big challenge in urban cities is solid waste management not only in India but in most countries in the world. Hence, such a system has to be built that can eradicate this problem or at least reduce it to the minimum level. Project Requirements Project Name Garbage Management Project (Using PHP & MYSQLi) Language Used PHP5.6, PHP7.x Database MySQL 5.x User Interface Design HTML, AJAX,JQUERY,JAVASCRIPT Web Browser Mozilla, Google Chrome, IE8, OPERA Software XAMPP / Wamp / Mamp/ Lamp (anyone) Project Modules The garbage management System Project is a Web-based application. In Garbage Management Project, we use PHP and MySQL database. It has three modules Admin Driver User Admin Module Admin is the super user of

Auto/Taxi Stand Management System using PHP and MySQL

Image
  “ Auto/Taxi Stand Management System ” is a web-based technology that will manage the records of the incoming and outgoing autos and taxis in a parking stand. It’s an easy for Admin to retrieve the data if the auto and taxi has been visited through the number he can get that data“Auto/Taxi Stand Management Project in PHP”  is an automatic system that delivers data processing in very high speed in a systematic manner. Project Requirements Project Name Auto/Taxi Stand Management System Project (Using PHP & MYSQLi) Language Used PHP5.6, PHP7.x Database MySQL 5.x User Interface Design HTML, AJAX,JQUERY,JAVASCRIPT Web Browser Mozilla, Google Chrome, IE8, OPERA Software XAMPP / Wamp / Mamp/ Lamp (anyone) Project Modules In “Auto/Taxi Stand Management System project”  we use PHP and MySQL database. This is the project which keeps records of the auto and taxi which is going to park in the stand. “Auto/Taxi Stand Management System”  have module i.e., admin and user. User User can only view