Insert data using modal php

 Open the config.php file and paste the below code in it.

Remember to include config files in all PHP files with the help of the include_once[] function. It is the main file that holds a database connection. So without a DB connection, you can not perform any DB operation into a database.

1.index.html


In this tutorial, I am going to show you how you can create a simple CRUD in Bootstrap 4 in PHP with search functionality.

What is CRUD?

  • Create a simple database table.
  • Reading / Fetch a database table data.
  • Update database table data.
  • Delete database table data.

Into your main folder create below folders and files.

  1. include [Folder].
  2. insert_data.php [file].
  3. connect_db.php [file].
  4. index.php [file].

Download the Database class from here and paste it into an included folder.

How to set up the config file.

Open the config.php file and paste the below code in it

.

Remember to include config files in all PHP files with the help of the include_once[] function. It is the main file that holds a database connection. So without a DB connection, you can not perform any DB operation into a database.

1.db [file].


CREATE TABLE `users` [
  `id` int[11] NOT NULL,
  `username` varchar[64] NOT NULL,
  `useremail` varchar[128] NOT NULL,
  `address` varchar[150] NOT NULL,
  `userphone` varchar[24] NOT NULL,
  `dt` timestamp NOT NULL DEFAULT current_timestamp[]
] ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
                                                                

2.connect_db.php [file].


   
$servername =   'localhost';
    $username   =   'root';
    $password   =   '';
    $dbname     =   "employee";
    $conn=mysqli_connect[$servername,$username,$password,"$dbname"];
    if[$conn === false]
    {
        die["ERROR: Could not connect. " . mysqli_connect_error[]];
    }
?>                                                                

3.insert_data.php [file].



Chủ Đề