How to creat insert function of php


config.php

<?php
 define('DB_SERVER', 'localhost');  
 define('DB_USERNAME', 'root');
 define('DB_PASSWORD', '');
 define('DB_DATABASE', 'student_db');
 
 
 
 define('PROJECT_NAME','Student Tutorial');
 define('SERVER_NAME','localhost');


class DB_Class
{
    function __construct()
    {
        $connection = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD,DB_DATABASE) or die('Oops connection error -> ' . mysqli_connect_error());
    }
}
$connection = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD,DB_DATABASE) or die('Oops connection error -> ' . mysqli_connect_error());

/**********************General WebSite Settings************************************/
date_default_timezone_set("UTC");
?>

class.dbFunctions.php

<?php
public $dbcon;
class Dbfunctions{
    
    public function __construct(){      
        $this->dbcon = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD,DB_DATABASE) or die('Oops connection error -> ' . mysqli_connect_error());                                
    }
    /* INSERT FUNCTION */
    public function insertSet($tblName,$string){		
		$rs= mysqli_query($this->dbcon,"INSERT INTO  " . $tblName . " SET " .  $string);
		if($rs){
			$lastId=mysqli_insert_id($this->dbcon);
			return $lastId;
		}else{
			$message="Error: " . $sql . "<br>" . mysqli_error($this->dbcon);
			return $message;
		}
	}
?>