Use the code below to insert any value in the database…

Any data when we have to add to the database, we need a query in it, in this query means the value that you want to insert, as well as the connection file is needed in it, this gives the address of mysqli_query It shows that he has to insert the data in which table of the database.

This : inlucde("connection.php");

This mysqli_query of connection file path.

 <?php $connection = mysqli_connect('localhost','database user','database password','tablename');?>

This code include(“connection.php”); would have been in

 

This Main code for Insert data in database using php form:-

 

First Code for Insert data in database

<?php inlucde("connection.php");                                                             $query="INSERT INTO `transactions` (`id`, `userid`, `fullname`, `description`, `credit`, `debit`, `balance`, `created_time`) VALUES (NULL, '8867676786Xx', 'naresh sir', 'this payment successfully done by upi', '1000', '0', '1200', '2022-01-09 16:46:00');";                                                                                                 $data = mysqli_query($connection,$query);                   ?>
HTML
Second Code for Insert data in database
<?php  $connection = mysqli_connect('localhost','datacode123','*******','datacode123');  $query="INSERT INTO `transactions` (`id`, `userid`, `fullname`, `description`, `credit`, `debit`, `balance`, `created_time`) VALUES (NULL, '8867676786Xx', 'naresh sir', 'this payment successfully done by upi', '1000', '0', '1200', '2022-01-09 16:46:00');";                                                                                                 $data = mysqli_query($connection,$query);                   ?>
HTML
Third Code for Insert data in database
<?php $connection = mysqli_connect('localhost','datacode123','*******','datacode123');                                                                                                  $data = mysqli_query($connection,"INSERT INTO `transactions` (`id`, `userid`, `fullname`, `description`, `credit`, `debit`, `balance`, `created_time`) VALUES (NULL, '8867676786Xx', 'naresh sir', 'this payment successfully done by upi', '1000', '0', '1200', '2022-01-09 16:46:00');");                   ?>

Leave a Reply

Your email address will not be published. Required fields are marked *