How to Insert Data in Database using PHP OOPS

How to Insert Data in Database using PHP OOPS

In this Post We Will Explain About is How to Insert Data in Database using PHP OOPS With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to how to fetch data from database in php using oops Example

In this post we will show you Best way to implement php mysql insert operation in PHP using OOP, hear for insert data in mysql using php class with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Setp 1.First create a html form

Index.php

	
USER Full Name :
USER Email :
USER Contact no. :
USER Gender : Male   Female
USER Education : Select Any one 10th 12th Graduate Post Graduate
USER Address :
 

Setp 2. Create a database with name demos

Inside demos content data base make a table inserdata
Sample some Structure of user_mst table

CREATE TABLE IF NOT EXISTS `user_mst` (
`id` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`phone` bigint(20) NOT NULL,
`user_gender` varchar(255) NOT NULL,
`user_edu` varchar(255) NOT NULL,
`user_user_address` longtext NOT NULL,
`posting_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1;

Setp 3. Create a php page function .php

Inside this simple page a using class DB_concreate or define. Db_con class contain simple database connection and some insert funtion.

function .php


Setp 4.Define a oject and class the insert funtion

Put this source code at the top of the simple root file index.php page

insert($user_fname,$email,$user_mobile,$user_gender,$user_edu,$adrss);
	if($sql)
	{
	echo "alert('USER Data inserted');";
	}
	else
	{
	echo "alert('USER Data not inserted');";
	}
}
 ?>

Example

I hope you have Got What is Objects Orientation in PHP And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Leave a Comment