PDO database insert script – PHP

PDO_MySQL, is the MySQL for PDO. PDO has been introduced in PHP, and the project aims to make a common API for all the databases access, so in theory you should be able to migrate between RDMS without changing any code (if you don’t use specific RDBM function in your queries), also object-oriented.

The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.

 

Here is the sample PDO script to insert data in to the database. This script will take the input from post method and insert that in to the database. Using this script to insert values in to the database is very simple. Just download the below code and modify the fields as per your requirements. Also make sure to add your database credentials as well.

Here is the database table

 

Good Luck!

I am a Software Engineer.

Leave a Reply

*

Next Articlemysql get the existing table code