如何在wordpress数据库中连接和插入数据?

On my website, there is a section called "My Ideal plank."

It is a form where the user will enter their data and there will be a return message with the type of ideal board for the person.

First step, make the form: Done;

Now do I need to connect and register the data in the database. I created a table in the Wordpress database called "minhaprancha". But I am not able to record the data on it: confused:

The connection code and registration is as follows:

global $wpdb;

  $nome = "";
  $email = "";
  $estilo = "";
  $experiencia = "";
  $altura = "";
  $peso = "";

  //VÁRIÁVEIS 
  if(!empty($_POST)){     
     $nome = $_POST['nome'];
     $email = $_POST['email'];
     $estilo = $_POST['estilo'];
     $experiencia = $_POST['experiencia'];
     $altura = $_POST['altura'];
     $peso = $_POST['peso'];


     cadastrar($nome,$email,$estilo,$experiencia,$altura,$peso);
     calcularIMC($estilo,$experiencia,$altura,$peso);

  }


  function cadastrar($nome,$email,$estilo,$experiencia,$altura,$peso){          //INSERE OS DADOS NO BANCO
      try{

         $wpdb->insert( "INSERT INTO aa_minhaprancha("."nome, email, estilo, experiencia, altura, peso) VALUES (". ":nome', ':email', ':estilo', ':experiencia', ':altura', ':peso')");

          if($wpdb->rowCount() > 0)
              return true;
          else
              return false;

      }catch(PDOException $e){
         echo "Erro ao incluir na tabela categoria ".$e->getMessage();
      }
  }

At first, how can I connect and register the data in the database?

----------------------- UPDATE ---------------------

I managed it! I made the connection in a direct way:

<?php
/*CONNECTION WITH DATABASE*/
define('DB_NAME', 'MYDB');
define('DB_USER', 'MYUSER');
define('DB_PASSWORD', 'MYPASS');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8mb4');
define('DB_COLLATE', '');


function conectar(){

    $dsn = "mysql:host=".DB_HOST.";dbname=".DB_NAME."";

    try{
        $conectar = new PDO($dsn, DB_USER, DB_PASSWORD);
        $conectar->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    }catch(PDOException $e)
    {
       echo "Erro ao conectar ao banco". $e->getMessage();
    }
    return $conectar;
}

the code of insert in database is the same. However, I change $wpdb for any variable.

In the wordpress reference is writed:

<?php $wpdb->insert( $table, $data, $format ); ?> 

where $data and $format are array.

First and foremost you should read the documentation on how to properly use $wpdb->insert()

  $nome = "";
  $email = "";
  $estilo = "";
  $experiencia = "";
  $altura = "";
  $peso = "";

  //VÁRIÁVEIS 
  if(!empty($_POST)){     
     $nome = $_POST['nome'];
     $email = $_POST['email'];
     $estilo = $_POST['estilo'];
     $experiencia = $_POST['experiencia'];
     $altura = $_POST['altura'];
     $peso = $_POST['peso'];


     cadastrar($nome,$email,$estilo,$experiencia,$altura,$peso);
     calcularIMC($estilo,$experiencia,$altura,$peso);

  }    

function cadastrar($nome,$email,$estilo,$experiencia,$altura,$peso){          //INSERE OS DADOS NO BANCO

        // the WPDB class is already setup for us let's make it accessible
        global $wpdb;

        // the name of our table
        $table = 'aa_minhaprancha';

        // data is an array with the format column_name => data
        $data = array(
          'nome' => $nome,
          'email' => $email,
          'estilo' => $estilo,
          'experiencia' => $experiencia,
          'altura' => $altura,
          'peso' => $peso,
        );

        // run the insert
        $inserted = $wpdb->insert( $table, $data );

        // if it didn't update get the error
        if ( ! $inserted ) {
          $wpbb->print_error();
        }

    }

Depending on the setup of your table you may need to include the additional $format parameter when inserting. This is an array of formats to be mapped to each of the values in $data