Why does the data i enter in the form doesn’t show in my database in phpMyAdmin? [closed]

In the following code, it takes the information of the user while submitting his message in a ‘Contact Us’ form, but when I click on the submit button, the database doesn’t show the data and it only shows me the massage “Message sent successfully.” , but if i upload a file, the file will be downloaded in my web server without it being shown in my db in phpMyAdmin.
I’m sure that the SQL code is perfect, since the db was made in phpMyAdmin. And how can i view a file that was uploaded and view it from phpMyAdmin?

<?php
// Database connection
$servername = "localhost";  
$username = "root";         
$password = "";             
$dbname = "contact_form_db"; 

$conn = new mysqli($servername, $username, $password, $dbname);

if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $name = mysqli_real_escape_string($conn, $_POST['name']);
    $email = mysqli_real_escape_string($conn, $_POST['email']);
    $phone = mysqli_real_escape_string($conn, $_POST['phone']);
    $message = mysqli_real_escape_string($conn, $_POST['message']);
    
    $file_path = '';
    if (isset($_FILES['file']) && $_FILES['file']['error'] == 0) {
        $file_tmp = $_FILES['file']['tmp_name'];
        $file_name = basename($_FILES['file']['name']);
        $file_size = $_FILES['file']['size'];
        $file_type = $_FILES['file']['type'];
        
        $allowed_types = ['image/jpeg', 'image/png', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'];
        $max_size = 5 * 1024 * 1024; 
        
        if (in_array($file_type, $allowed_types) && $file_size <= $max_size) {
            $upload_dir = 'uploads/';
            
            if (!is_dir($upload_dir)) {
                mkdir($upload_dir, 0755, true);
            }
            
            $unique_file_name = uniqid('file_') . "_" . $file_name;
            $file_path = $upload_dir . $unique_file_name;
            
            if (move_uploaded_file($file_tmp, $file_path)) {
                echo "<p>File uploaded successfully!</p>";
            } else {
                echo "<p>There was an error uploading your file.</p>";
            }
        } else {
            echo "<p>Invalid file type or size. Please upload a valid file.</p>";
        }
    }

    $sql = "INSERT INTO contact_info (Name, Email, Phone, Message, FilePath) 
            VALUES ('$name', '$email', '$phone', '$message', '$file_path')";
    
    if ($conn->query($sql) === TRUE) {
        echo "<p>Message sent successfully!</p>";
    } else {
        echo "<p>Error: " . $conn->error . "</p>";
    }

    $conn->close();
}

?>




<!-- Contact Form -->
<div class="contact-form-container">
    <div class="contact-info-left">
        <h2>Contact Us</h2>
        <div class="contact-details">
            <p><i class="fas fa-map-marker-alt"></i> Zone 2, 3rd Floor, KOM4<br>
            Knowledge Oasis Muscat<br>
            PO Box 35, PC 135 Rusayl<br>
            Sultanate of Oman</p><br>
            <p><i class="fas fa-phone-alt"></i> 80077767 / +968 2417 1111</p><br>
            <p><i class="fas fa-clock"></i> from 8 AM - 5:30 PM</p><br> 
        </div>
    </div>
    <form class="contact-form" method="POST" action="" enctype="multipart/form-data">
    <!-- Personal Information Section -->
    <div class="form-section">
        <h3>Personal Information</h3>
        <label for="name">Name</label>
        <input type="text" id="name" name="name" pattern="[A-Za-z]+" title="Only letters are allowed" required>
        
        <label for="phone">Phone Number</label>
        <input type="tel" id="phone" name="phone" pattern="[0-9]{8,15}" title="Phone number should contain only numbers and be 8 to 15 digits long" required oninput="this.value = this.value.replace(/[^0-9]/g, '');">
        
        <label for="email">Email</label>
        <input type="email" id="email" name="email" required>
        <label for="file">Attach File (optional)</label>
        <input type="file" id="file" name="file" accept="image/*,.pdf,.docx,.txt">

    </div>
    
    <!-- Message Details Section -->
    <div class="form-section">
        <h3>Message Details</h3>
        <label for="message">Message</label>
        <textarea id="message" name="message" rows="10" required></textarea>
    </div>

    <button type="submit">Send Message</button>
    
</form>
<script>
function submitForm(event) {
    event.preventDefault(); 
    
    alert("Message sent successfully!"); 
}
</script>
</div>

I don’t know if the HTML code has something to do with it, but I did try to get help from ChatGPT and it keeps saying that there is no problem with the code. And sometimes it changes many things in the code and makes it completely different.
I’ve tried to change the variables names but It still did not work.