PRUEBA_1

Este código sirve para hacer una sistema en donde gestiona la tareas

<?php
function RegistrarCategoria($nombre, $conn) {
    $sql = "INSERT INTO categoria (nombre) VALUES (:nombre)";
    try {
        $stmt = $conn->prepare($sql);
        $stmt->bindParam(':nombre', $nombre, PDO::PARAM_STR);
        
        // Verificar si la ejecución fue exitosa
        if ($stmt->execute()) {
           
        } else {
            echo "Error al ejecutar la consulta<br>";
        }
    } catch (PDOException $e) {
        echo "Error en la inserción: " . $e->getMessage();
    }
}
?>
<?php
$host = "localhost";
$user = "root";
$password = "";
$dbname = "tareasdb";

try {
    $conn = new PDO("mysql:host=$host;dbname=$dbname;charset=utf8", $user, $password);
    // Establer el modo de error de PDO a excepción
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);    
} catch (PDOException $e) {
    die("Conexion fallida: " . $e->getMesagge());
}
?>
<?php
include 'conexiont.php';
include 'categoria.php';
$mensaje = '';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $nombre = $_POST['nombre'];

    // Verificar que la función existe antes de llamarla
    if (function_exists('RegistrarCategoria')) {
        RegistrarCategoria($nombre, $conn);
        $mensaje = "Categoría añadida exitosamente.";
    } else {
        $mensaje = "Error: La función 'RegistrarCategoria' no está definida.";
    }
     $conn = null;
}
?>

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Registro de Categoría</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f9;
            display: flex;
            height: 100vh;
        }
        .sidebar {
            width: 350px;
            background-color: #28a745;
            padding: 20px;
            color: white;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        .sidebar h2 {
            margin-bottom: 20px;
        }
        .form-container {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            background-color: #ffffff;
            position: relative;
        }
        form {
            background-color: #f4f4f9;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 500px;
        }
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
        }
        input {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
        button {
            background-color: #28a745;
            color: white;
            border: none;
            padding: 10px;
            cursor: pointer;
            width: 100%;
            border-radius: 5px;
            transition: background-color 0.3s ease;
        }
        button:hover {
            background-color: #1e7e34;
        }
        .success {
            text-align: center;
            color: green;
            margin-top: 15px;
        }
        .buttons {
            text-align: center;
            margin-top: 20px;
        }
        .buttons a {
            display: inline-block;
            margin: 10px;
            padding: 10px 20px;
            background-color: #1e7e34;
            color: white;
            text-decoration: none;
            border-radius: 5px;
        }
        .buttons a:hover {
            background-color: #0056b3;
        }
        /* Estilo del botón superior derecho */
        .top-right-button {
            position: absolute;
            top: 20px;
            right: 20px;
        }
        .top-right-button a {
            background-color: #1e7e34;
            color: white;
            text-decoration: none;
            padding: 10px 20px;
            border-radius: 5px;
        }
        .top-right-button a:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <!-- Sidebar izquierda -->
    <div class="sidebar">
        <h2>Registrar Nueva Categoría</h2>
        <p>Añade una nueva Categoria.</p>
    </div>

    <!-- Contenedor del formulario y mensaje -->
    <div class="form-container">
        <!-- Botón de ir al inicio en la esquina superior derecha -->
        <div class="top-right-button">
            <a href="index.php">Inicio</a>
        </div>

        <?php if ($mensaje === ''): ?>
            <!-- Mostrar formulario si no se ha enviado todavía -->
            <form action="formcat.php" method="POST">
                <label for="nombre">Nombre de la Categoría:</label>
                <input type="text" id="nombre" name="nombre" placeholder="Ej. Marketing" required>
                <button type="submit">Registrar</button>
            </form>
        <?php else: ?>

            <div class="success"><?php echo $mensaje; ?></div>
            <div class="buttons">
                <a href="index.php">Volver al Inicio</a>
                <a href="formcat.php">Añadir Otra Categoría</a>
            </div>
        <?php endif; ?>
    </div>
</body>
</html>
<?php
include 'conexiont.php';
include 'responsable.php';
$mensaje = '';

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $nombre = $_POST['nombre'];
    $whatsapp = $_POST['whatsapp'];
    $departamento = $_POST['departamento'];

    // Verificar que la función existe antes de llamarla
    if (function_exists('RegistrarResponsable')) {
        RegistrarResponsable($nombre, $whatsapp, $departamento, $conn);
        $mensaje = "Responsable añadido exitosamente.";
    } else {
        $mensaje = "Error: La función 'RegistrarResponsable' no está definida.";
    }
}
?>

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Registro de Responsable</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f9;
            display: flex;
            height: 100vh;
        }

        /* Estilo de la barra lateral */
        .sidebar {
            width: 350px;
            background-color: #17a2b8; /* Azul claro */
            padding: 20px;
            color: white;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }

        .sidebar h2 {
            margin-bottom: 20px;
        }

        /* Estilo del contenedor del formulario */
        .form-container {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            background-color: #ffffff;
            position: relative;
        }

        form {
            background-color: #f4f4f9;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 500px;
        }

        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
        }

        input {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }

        button {
            background-color: #17a2b8; /* Azul claro */
            color: white;
            border: none;
            padding: 10px;
            cursor: pointer;
            width: 100%;
            border-radius: 5px;
            transition: background-color 0.3s ease, transform 0.3s ease; /* Animación de hover */
        }

        button:hover {
            background-color: #138496; /* Azul más oscuro */
            transform: scale(1.1); /* Aumenta el tamaño del botón */
        }

        .success {
            text-align: center;
            color: green;
            margin-top: 15px;
        }

        .error {
            text-align: center;
            color: red;
            margin-top: 15px;
        }

        /* Botón superior derecho */
        .top-right-button {
            position: absolute;
            top: 20px;
            right: 20px;
        }

        .top-right-button a {
            background-color: #007bff;
            color: white;
            text-decoration: none;
            padding: 10px 20px;
            border-radius: 5px;
        }

        .top-right-button a:hover {
            background-color: #0056b3;
        }

        /* Botón para registrar otro responsable */
        .button-container {
            display: flex;
            justify-content: center;
            margin-top: 20px;
        }

        .button-container a {
            background-color: #17a2b8; /* Azul claro */
            color: white;
            text-decoration: none;
            padding: 10px 20px;
            border-radius: 5px;
            transition: background-color 0.3s ease, transform 0.3s ease;
        }

        .button-container a:hover {
            background-color: #138496;
            transform: scale(1.1); /* Animación de agrandamiento */
        }
    </style>
</head>
<body>
    <!-- Sidebar izquierda -->
    <div class="sidebar">
        <h2>Registrar Responsable</h2>
        <p>Añade un nuevo Responsable.</p>
    </div>

    <!-- Contenedor del formulario y mensaje -->
    <div class="form-container">
        <!-- Botón de ir al inicio en la esquina superior derecha -->
        <div class="top-right-button">
            <a href="index.php">Inicio</a>
        </div>

        <?php if ($mensaje === ''): ?>
            <!-- Formulario para registrar un responsable -->
            <form action="formres.php" method="POST">
                <label for="nombre">Nombre del Responsable:</label>
                <input type="text" id="nombre" name="nombre" placeholder="Ej. Juan Pérez" required>

                <label for="whatsapp">Número de WhatsApp:</label>
                <input type="text" id="whatsapp" name="whatsapp" placeholder="Ej. +52 123 456 7890" required>

                <label for="departamento">Departamento:</label>
                <input type="text" id="departamento" name="departamento" placeholder="Ej. Recursos Humanos" required>

                <button type="submit">Registrar</button>
            </form>
        <?php else: ?>
            <!-- Mostrar mensaje de éxito después de registrar -->
            <div class="success"><?php echo $mensaje; ?></div>
            <!-- Botón para registrar otro responsable -->
            <div class="button-container">
                <a href="formres.php">Registrar otro responsable</a>
            </div>
        <?php endif; ?>
    </div>
</body>
</html>
<?php
include 'conexiont.php';  // Conexión a la base de datos
include 'tareas.php';     // Asegúrate de incluir el archivo donde está la función RegistrarTareas
$mensaje = '';

// Obtener las categorías y responsables desde la base de datos
$queryCategorias = "SELECT idcat, nombre FROM Categoria";
$categorias = $conn->query($queryCategorias)->fetchAll(PDO::FETCH_ASSOC);

$queryResponsables = "SELECT idres, nombre FROM Responsable";
$responsables = $conn->query($queryResponsables)->fetchAll(PDO::FETCH_ASSOC);

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Obtener datos del formulario
    $nombretarea = $_POST['nombretarea'];
    $estado = $_POST['estado'];
    $fechacreacion = $_POST['fechacreacion'];
    $fechafinal = $_POST['fechafinal'];
    $idcat = $_POST['idcat'];
    $idres = $_POST['idres'];

    // Verificar que la función existe antes de llamarla
    if (function_exists('RegistrarTareas')) {
        RegistrarTareas($nombretarea, $estado, $fechacreacion, $fechafinal, $idcat, $idres, $conn);
        $mensaje = "Tarea añadida exitosamente.";
    } else {
        $mensaje = "Error: La función 'RegistrarTareas' no está definida.";
    }
}
?>

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Registro de Tarea</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f9;
            display: flex;
            height: 100vh;
        }
        .sidebar {
            width: 350px;
            background-color: #ff6f00; /* Color naranja */
            padding: 20px;
            color: white;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        .sidebar h2 {
            margin-bottom: 20px;
        }
        .form-container {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            background-color: #ffffff;
            position: relative;
        }
        form {
            background-color: #f4f4f9;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 500px;
        }
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: bold;
        }
        input, select {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ddd;
            border-radius: 5px;
        }
        button {
            background-color: #ff6f00; /* Color naranja */
            color: white;
            border: none;
            padding: 10px;
            cursor: pointer;
            width: 100%;
            border-radius: 5px;
            transition: background-color 0.3s ease;
        }
        button:hover {
            background-color: #e65c00;
        }
        .success {
            text-align: center;
            color: green;
            margin-top: 15px;
        }
        .buttons {
            text-align: center;
            margin-top: 20px;
        }
        .buttons a {
            display: inline-block;
            margin: 10px;
            padding: 10px 20px;
            background-color: #ff6f00; /* Color naranja */
            color: white;
            text-decoration: none;
            border-radius: 5px;
        }
        .buttons a:hover {
            background-color: #e65c00;
        }
        /* Estilo del botón superior derecho */
        .top-right-button {
            position: absolute;
            top: 20px;
            right: 20px;
        }
        .top-right-button a {
            background-color: #ff6f00; /* Color naranja */
            color: white;
            text-decoration: none;
            padding: 10px 20px;
            border-radius: 5px;
        }
        .top-right-button a:hover {
            background-color: #e65c00;
        }
    </style>
</head>
<body>
    <!-- Sidebar izquierda -->
    <div class="sidebar">
        <h2>Registrar Nueva Tarea</h2>
        <p>Añade una nueva tarea.</p>
    </div>

    <!-- Contenedor del formulario y mensaje -->
    <div class="form-container">
        <!-- Botón de ir al inicio en la esquina superior derecha -->
        <div class="top-right-button">
            <a href="index.php">Inicio</a>
        </div>

        <?php if ($mensaje === ''): ?>
            <!-- Mostrar formulario si no se ha enviado todavía -->
            <form action="formtareas.php" method="POST">
                <label for="nombretarea">Nombre de la Tarea:</label>
                <input type="text" id="nombretarea" name="nombretarea" placeholder="Ej. Diseño Gráfico" required>

                <label for="estado">Estado:</label>
                <select name="estado" id="estado" required>
                    <option value="">Seleccionar Estado</option>
                    <option value="Pendiente">Pendiente</option>
                    <option value="En progreso">En progreso</option>
                    <option value="Completada">Completada</option>
                </select>

                <label for="fechacreacion">Fecha de Creación:</label>
                <input type="date" id="fechacreacion" name="fechacreacion" required>

                <label for="fechafinal">Fecha de Finalización:</label>
                <input type="date" id="fechafinal" name="fechafinal" required>

                <label for="idcat">Categoría:</label>
                <select name="idcat" id="idcat" required>
                    <option value="">Seleccionar Categoría</option>
                    <?php 
                    foreach ($categorias as $categoria): ?>
                        <option value="<?php echo $categoria['idcat']; ?>">
                            <?php echo htmlspecialchars($categoria['nombre']); ?>
                        </option>
                    <?php endforeach; ?>
                </select>

                <label for="idres">Responsable:</label>
                <select name="idres" id="idres" required>
                    <option value="">Seleccionar Responsable</option>
                    <?php 
                    foreach ($responsables as $responsable): ?>
                        <option value="<?php echo $responsable['idres']; ?>">
                            <?php echo htmlspecialchars($responsable['nombre']); ?>
                        </option>
                    <?php endforeach; ?>
                </select>

                <button type="submit">Registrar</button>
            </form>
        <?php else: ?>
            <div class="success"><?php echo $mensaje; ?></div>
            <div class="buttons">
                <a href="index.php">Volver al Inicio</a>
                <a href="formtareas.php">Añadir Otra Tarea</a>
            </div>
        <?php endif; ?>
    </div>
</body>
</html>
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Gestión de Tareas</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }

        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f9;
            display: flex;
            height: 100vh;
        }

        /* Barra lateral */
        .sidebar {
            width: 250px;
            background-color: #003366; /* Azul oscuro */
            color: white;
            padding: 20px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            height: 100%;
        }

        .sidebar h2 {
            font-size: 24px;
            margin-bottom: 20px;
        }

        /* Contenido principal */
        .content {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        h1 {
            font-size: 36px;
            color: #333;
            margin-bottom: 30px;
        }

        .button {
            background-color: #003366; /* Azul oscuro */
            color: white;
            border: none;
            padding: 20px 40px;
            font-size: 18px;
            border-radius: 8px;
            cursor: pointer;
            width: 200px;
            margin: 10px 0;
            transition: transform 0.3s ease, background-color 0.3s ease;
        }

        .button:hover {
            transform: scale(1.1); /* Aumenta el tamaño del botón */
            background-color: #00509e; /* Cambio de color al pasar el ratón */
        }

        .buttons-container {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
    </style>
</head>
<body>
    <!-- Barra lateral -->
    <div class="sidebar">
        <h2>Control de Tareas</h2>
        <div>
            <button class="button" onclick="window.location.href='formcat.php'">Añadir Categoría</button>
            <button class="button" onclick="window.location.href='formres.php'">Añadir Responsable</button>
            <button class="button" onclick="window.location.href='formtareas.php'">Añadir Tarea</button>
            <button class="button" onclick="window.location.href='listado.php'">Listado de Tareas</button>
        </div>
    </div>

    <!-- Contenido principal -->
    <div class="content">
        <h1>Gestión de Tareas</h1>

        <!-- Contenedor de los botones (en la barra lateral) -->
        <div class="buttons-container">
            <!-- Los botones ya están en la barra lateral -->
        </div>
    </div>
</body>
</html>
<?php
include 'conexiont.php';  // Asegúrate de que la conexión a la base de datos esté correctamente configurada

// Obtener el estado y nombre del responsable filtrados si están disponibles
$estadoFiltrado = isset($_GET['estado']) ? $_GET['estado'] : '';
$responsableFiltrado = isset($_GET['responsable']) ? $_GET['responsable'] : '';

// Consulta para obtener todas las tareas, responsables y categorías
$sql = "SELECT tareas.nombretarea, tareas.estado, tareas.fechacreacion, tareas.fechafinal, 
               responsable.nombre AS responsable, categoria.nombre AS categoria
        FROM tareas
        INNER JOIN responsable ON tareas.idres = responsable.idres
        INNER JOIN categoria ON tareas.idcat = categoria.idcat";

// Añadir condiciones de filtro si están presentes
$conditions = [];
if ($estadoFiltrado != '') {
    $conditions[] = "tareas.estado = :estadoFiltrado";
}
if ($responsableFiltrado != '') {
    $conditions[] = "responsable.nombre LIKE :responsableFiltrado";
}

// Si hay condiciones, agregarlas a la consulta
if (count($conditions) > 0) {
    $sql .= " WHERE " . implode(' AND ', $conditions);
}

try {
    // Preparar la consulta
    $stmt = $conn->prepare($sql);

    // Vincular parámetros para estado y responsable, si es necesario
    if ($estadoFiltrado != '') {
        $stmt->bindParam(':estadoFiltrado', $estadoFiltrado, PDO::PARAM_STR);
    }
    if ($responsableFiltrado != '') {
        $responsableFiltrado = "%" . $responsableFiltrado . "%";  // Usar LIKE para búsqueda parcial
        $stmt->bindParam(':responsableFiltrado', $responsableFiltrado, PDO::PARAM_STR);
    }

    // Ejecutar la consulta
    $stmt->execute();

    // Obtener los resultados
    $tareas = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
    echo "Error al obtener las tareas: " . $e->getMessage();
}
?>

<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Listado de Tareas</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f5f5dc; /* Color crema */
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 20px;
        }
        table {
            width: 80%;
            margin-top: 20px;
            border-collapse: collapse;
            text-align: left;
        }
        th, td {
            padding: 10px;
            border: 1px solid #ddd;
        }
        th {
            background-color: #dc3545;
            color: white;
        }
        tr:nth-child(even) {
            background-color: #fafafa;
        }
        tr:hover {
            background-color: #f8d7da;
        }
        .top-right-button {
            position: absolute;
            top: 20px;
            right: 20px;
        }
        .top-right-button a {
            background-color: #dc3545;
            color: white;
            text-decoration: none;
            padding: 10px 20px;
            border-radius: 5px;
        }
        .top-right-button a:hover {
            background-color: #c82333;
        }
        select, input, button {
            margin: 20px;
            padding: 10px;
            border-radius: 5px;
            border: 1px solid #ddd;
        }
    </style>
</head>
<body>
    <!-- Botón de ir al inicio en la esquina superior derecha -->
    <div class="top-right-button">
        <a href="index.php">Inicio</a>
    </div>

    <h1>Listado de Tareas</h1>

    <!-- Formulario de filtro por estado y nombre del responsable -->
    <form method="GET" action="listado.php">
        <label for="estado">Filtrar por estado:</label>
        <select name="estado" id="estado">
            <option value="">Selecciona un estado</option>
            <option value="Pendiente" <?php if ($estadoFiltrado == 'Pendiente') echo 'selected'; ?>>Pendiente</option>
            <option value="En Progreso" <?php if ($estadoFiltrado == 'En Progreso') echo 'selected'; ?>>En Progreso</option>
            <option value="Completada" <?php if ($estadoFiltrado == 'Completada') echo 'selected'; ?>>Completada</option>
        </select>

        <label for="responsable">Buscar por responsable:</label>
        <input type="text" id="responsable" name="responsable" value="<?php echo htmlspecialchars($responsableFiltrado); ?>" placeholder="Nombre del responsable">

        <button type="submit">Filtrar</button>
    </form>

    <?php if (count($tareas) > 0): ?>
        <table>
            <thead>
                <tr>
                    <th>Nombre de la Tarea</th>
                    <th>Estado</th>
                    <th>Fecha de Creación</th>
                    <th>Fecha de Finalización</th>
                    <th>Responsable</th>
                    <th>Categoría</th>
                </tr>
            </thead>
            <tbody>
                <?php foreach ($tareas as $tarea): ?>
                    <tr>
                        <td><?php echo htmlspecialchars($tarea['nombretarea']); ?></td>
                        <td><?php echo htmlspecialchars($tarea['estado']); ?></td>
                        <td><?php echo htmlspecialchars($tarea['fechacreacion']); ?></td>
                        <td><?php echo htmlspecialchars($tarea['fechafinal']); ?></td>
                        <td><?php echo htmlspecialchars($tarea['responsable']); ?></td>
                        <td><?php echo htmlspecialchars($tarea['categoria']); ?></td>
                    </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
    <?php else: ?>
        <p>No hay tareas registradas.</p>
    <?php endif; ?>
</body>
</html>
<?php
function RegistrarResponsable($nombre, $whatsapp, $departamento, $conn) {

     $sql = "INSERT INTO responsable (nombre, whatsapp, departamento) VALUES (:nombre, :whatsapp, :departamento)";
    
    try {
        $stmt = $conn->prepare($sql);
        $stmt->bindParam(':nombre', $nombre, PDO::PARAM_STR);
        $stmt->bindParam(':whatsapp', $whatsapp, PDO::PARAM_STR);
        $stmt->bindParam(':departamento', $departamento, PDO::PARAM_STR);
        
        // Verificar si la consulta se ejecutó correctamente
        if ($stmt->execute()) {
            
        } else {
            echo "Error al ejecutar la consulta<br>";
        }
    } catch (PDOException $e) {
        echo "Error en la inserción: " . $e->getMessage();
    }
}
?>
<?php
// tareas.php
function RegistrarTareas($nombretarea, $estado, $fechacreacion, $fechafinal, $idcat, $idres, $conn) {
    try {
        // Consulta SQL para insertar los datos
        $sql = "INSERT INTO Tareas (nombretarea, estado, fechacreacion, fechafinal, idcat, idres)
                VALUES (:nombretarea, :estado, :fechacreacion, :fechafinal, :idcat, :idres)";
        
        $stmt = $conn->prepare($sql);
        
        // Asignar valores a los parámetros
        $stmt->bindParam(':nombretarea', $nombretarea);
        $stmt->bindParam(':estado', $estado);
        $stmt->bindParam(':fechacreacion', $fechacreacion);
        $stmt->bindParam(':fechafinal', $fechafinal);
        $stmt->bindParam(':idcat', $idcat);
        $stmt->bindParam(':idres', $idres);
        
        // Ejecutar la consulta
        $stmt->execute();
        
        return true;
    } catch (PDOException $e) {
        // Si hay un error, lo mostramos
        echo "Error al insertar tarea: " . $e->getMessage();
        return false;
    }
}
?>

Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *