<?php
include 'nombre.php';
include 'conexion.php';

if (isset($_FILES['imagen']) && isset($_POST['nombre']) && isset($_POST['caracteristicas']) && isset($_POST['precio'])) {
    $nombre = $_POST["nombre"];
    $precio = $_POST["precio"];
    $caracteristicas = $_POST["caracteristicas"];
    $archivo_temporal = $_FILES['imagen']['tmp_name'];
    $nombre_archivo = $_FILES['imagen']['name'];
    $carpeta_destino = 'img/';

    if (move_uploaded_file($archivo_temporal, $carpeta_destino . $nombre_archivo)) {
        $query = "INSERT INTO productos (nombre, imagen, precio, caracteristicas) VALUES (' $nombre','$nombre_archivo', '$precio', '$caracteristicas')";
        $execute = $conectado->prepare($query);
     
        
        if ($execute->execute()) {
            echo "Producto agregado correctamente.";
        } else {
            echo "Error al agregar el producto: " . $execute->error;
        }

        $execute->close();
    }
}
?>
<html lang="en">
<head>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" 
    integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
    <script src="https://cdn.jsdelivr.net/npm/uikit@3.18.3/dist/js/uikit.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/uikit@3.18.3/dist/js/uikit-icons.min.js"></script>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/uikit@3.18.3/dist/css/uikit.min.css" />
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="Estilos/index.css">
    <script src="https://unpkg.com/feather-icons"></script>
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" 
    integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anony">
    <title>gay</title>
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #f2f2f2;
        }

        .custom-form {
            max-width: 400px;
            margin: 50px auto;
            padding: 20px;
            background-color: #ffffff;
            border-radius: 8px;
            box-shadow: 0px 0px 10px 0px #000000;
            margin-top: 200px;
        }

        .custom-input, .custom-select {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
        }

        .custom-select {
            appearance: none;
            -webkit-appearance: none;
            -moz-appearance: none;
            background: url('https://imageurl.com/down-arrow.png') no-repeat right #fff;
            background-size: 20px;
        }

        .custom-submit {
            background-color: #4CAF50;
            color: #fff;
            padding: 10px 15px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }

        .custom-submit:hover {
            background-color: #45a049;
        }

        .custom-heading {
            text-align: center;
            color: #333;
        }

        .chat-icon {
    position: fixed;
    bottom: 20px; /* Distancia desde la parte inferior */
    right: 20px; /* Distancia desde el lado derecho */
    background-color: #3056C4;
    color: #ffffff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: transform 0.3s ease;
}

.chat-icon:hover {
    transform: scale(1.1); /* Efecto de escala al pasar el mouse */
}
    </style>
</head>
<body>
<?php include 'menu2.php'; ?>

<form action="" method="post" class="custom-form" enctype="multipart/form-data">
    <h2 class="custom-heading">Agregar Producto</h2>
    <input type="text" class="custom-input fadeIn second" name="nombre" placeholder="Nombre" required>
    <input type="text" class="custom-input fadeIn third" name="precio" placeholder="precio" required>
    <input type="text" class="custom-input fadeIn second" name="caracteristicas" placeholder="caracteristicas" required>
    <input type="file" class="custom-input fadeIn second" name="imagen" placeholder="imagen" required>

    <input type="submit" class="custom-submit fadeIn fourth" value="Agregar producto">
</form>

<div class="chat-icon">
    <?php include("boticon.php") ?>
    </div>

</body>
</html>
