如何使用php和mysql从表中捕获ID

my question is:

How to capture ID of a table with a statement prepared in php and mysql to assign this ID that was captured and add through an insert as the foreign key of the following table.

Basically I have two tables 'Cliente' and 'Direccion' so I want the ID (pk) from Cliente and put that ID (after the first query) in the ID(fk) from Direccion for both tables are related .

When i try to run the form in my page this message error appears:

Fatal error: Uncaught Error: Call to a member function mysqli_insert_id() on string in
C:\xampp\htdocs\compra\compraegistro\FormRegistro_reg.php:31 Stack trace: #0 {main} thrown in
C:\xampp\htdocs\compra\compraegistro\FormRegistro_reg.php on line 31

here's the code:

<?php

//Table Cliente
$nom = $_POST["nombre"];
$ape = $_POST["apellido"];
$mail = $_POST["correo"];
$obs = $_POST["observacion"];
$con = $_POST["contrasena"];
$rut = $_POST["rut"];
$fono = $_POST["num_telefono"];

// Table Dirección
$calle = $_POST["calle"];
$num = $_POST["num_calle"];
$com = $_POST["comuna"];
$reg = $_POST["region"];



require('otraconexion.php');


    //Query Table Cliente

    $sql = "INSERT INTO cliente VALUES (NULL,?,?,?,?,?,?,?)";
    $resultado = mysqli_prepare($conexion, $sql);


$ok = mysqli_stmt_bind_param($resultado,"ssssisi",$nom,$ape,$mail,$obs,$con,$rut,$fono);
$ok = mysqli_stmt_execute($resultado);
$fk = $sql->mysqli_insert_id();

//Query Table Dirección

$sql2 = "INSERT INTO direccion VALUES (NULL,?,?,?,?,?)";
$resultado2 = mysqli_prepare($conexion, $sql2);

if(!$resultado2){
echo "Error al insertar.".mysqli_error($conexion);
}

$ok = mysqli_stmt_bind_param($resultado2,"sissi",$calle,$num,$com,$reg,$fk);
$ok = mysqli_stmt_execute($resultado2);



if($ok==false){

    echo"Error,";
}else{

    header("Location: ../Acceso/Indexp.php");

}

mysqli_stmt_close($resultado);


?>