<?php
$host="localhost";
$user="lara";
$pass="myLARA"; 
$base="lara1";

$marca="Uso Real";
$anio="2022";

$userAgent = $_SERVER['HTTP_USER_AGENT'];
$userIP = $_SERVER['REMOTE_ADDR'];
$referer = $_SERVER['HTTP_REFERER'];
$currentPage = $_SERVER['REQUEST_URI'];

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // Make MySQLi throw exceptions.

        try {
            // Try Connect to the DB with new MySqli object - Params {hostname, userid, password, dbname}
            $mysqli = new mysqli($host, $user, $pass, $base);
         
            $query = "insert into log(tipo,log) values('spy','".$userIP."|".$currentPage."|".$userAgent."')";
            $mysqli->query($query);
        
        }catch (mysqli_sql_exception $e) { // Failed to connect? Lets see the exception details..
            echo "MySQLi Error Code: " . $e->getCode() . "<br />";
            echo "Exception Msg: " . $e->getMessage();
            exit; // exit and close connection.
        }

        $mysqli->close(); // finally, close the connection
  
?>