I used "wpdb" in my code But it was not working and the following error:
Fatal error: Call to a member function insert() on a non-object
Notice: Trying to get property of non-object" in tablename = $wpdb->prefix.'complaint';
global $wpdb;
$name = $_POST["name"];
$email = $_POST["email"];
$dis = $_POST["dis"];
$code = $_POST["code"];
function insert_record_to_db($name,$email,$dis){
global $wpdb;
$tablename = $wpdb->prefix.'complaint';
$data=array(
'name' => '$name',
'email' => '$email',
'dis' => '$dis'
);
$format= array('%s','%s','%s');
$wpdb->insert( $tablename , $data , $format );
};
insert_record_to_db($name,$email,$dis);