In this post I will explain how to insert data in database using oops concept.
1.First create a html form
Index.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | Full Name:
Email: Contact no.: Gender: Male Female Education: Select 10th 12th Graduate Post Graduate Address:
|
2. Create a database with name demos
Inside demos data base create a table inserdata
Sample Structure of insertdata table
CREATE TABLE IFNOTEXISTS`insertdata`[ `id`int[11]NOTNULL, `name` varchar[255]NOTNULL, `email`varchar[255]NOTNULL, `contactno`bigint[20] NOTNULL, `gender`varchar[255]NOTNULL, `education`varchar[255]NOTNULL, `addrss` longtext NOTNULL, `posting_date`timestamp NOTNULLDEFAULTCURRENT_TIMESTAMP ]ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULTCHARSET=latin1; |
3. Create a php page function .php
Inside this page a class DB_con define. Db_con class contain db connection and insert funtion.
function .php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
Chủ Đề |