<repo_name>Valmos22/CRUD---PHP-MYSQl<file_sep>/pagina_inicio.php
<?php include("db.php"); ?>

<?php include('includes/header.php'); ?>

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="estilos.css">
    <title>Inicio</title>
</head>

<body>
    <main class="container p-4">
        <div class="row">
            <div class="col-md-12" style="height: 100%; ">
                <!-- <div>
                    <h5>Esto es la pagina inicial</h5>
                </div> -->
                <div>
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="card" style="height: 100%; border-radius: 20px; margin-top:30px; box-shadow: 4px 6px 8px grey;">
                                <div class="card-body" >
                                    <h5 class="card-title" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;">Especialízate ahora mismo</h5>
                                    <p class="card-text">With supporting text below as a natural lead-in to additional
                                        content.</p>
                                    <a href="#" style="box-shadow: 4px 6px 8px grey;" class="btn btn-outline-dark rounded-pill">Conoce mas</a>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-6">
                            <div class="card" style="height: 100%; border-radius: 20px; margin-top:30px; box-shadow: 4px 6px 8px grey;">
                                <div class="card-body">
                                    <h5 class="card-title" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;">Especialízate ahora mismo</h5>
                                    <p class="card-text">With supporting text below as a natural lead-in to additional
                                        content.</p>
                                    <a href="#" style="box-shadow: 4px 6px 8px grey;" class="btn btn-outline-dark rounded-pill">Conoce mas</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="col-md-12 container" style="height: 100%; border-radius: 20px; margin-top:80px;">
                <p>
                    <h2 style="text-align: center; text-shadow: 2px 2px 5px black;">Estudia desde cero o especialízate en las áreas con mayor demanda laboral</h2>
                </p>
                <div style="display: flex; justify-content: center; align-items: center;">
                    <div class="row row-cols-3" style="border-radius: 20px; margin-top:30px;">
                        <div class="col">
                            <div class="card" style="border-radius: 20px; box-shadow: 4px 6px 8px grey; background-color: rgba(78, 77, 80, 0.5);">
                                <div class="card-body">
                                    <h6 class="card-title">Estudia:</h6>
                                    <a href="#" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;" class="card-link">Finanzas Personales</a>
                                </div>
                            </div>
                        </div>
                        
                        <div class="col">
                            <div class="card" style="border-radius: 20px; background-color: rgba(78, 77, 80, 0.5); box-shadow: 4px 6px 8px grey;">
                                <div class="card-body">
                                <h6 class="card-title">Estudia:</h6>
                                    <a href="#" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;" class="card-link">Periodismo Digital</a>
                                </div>
                            </div>
                        </div>

                        <div class="col">
                            <div class="card" style="border-radius: 20px; background-color: rgba(78, 77, 80, 0.5); box-shadow: 4px 6px 8px grey;">
                                <div class="card-body">
                                <h6 class="card-title">Estudia:</h6>
                                    <a href="#" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;" class="card-link">Produccion Audiovisual</a>
                                </div>
                            </div>
                        </div>

                        <div class="col" style="border-radius: 20px; margin-top:30px;">
                            <div class="card" style="border-radius: 20px; background-color: rgba(78, 77, 80, 0.5); box-shadow: 4px 6px 8px grey;">
                                <div class="card-body">
                                <h6 class="card-title">Estudia:</h6>
                                    <a href="#" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;" class="card-link">Negocios</a>
                                </div>
                            </div>
                        </div>

                        <div class="col" style="border-radius: 20px; margin-top:30px;">
                            <div class="card" style="border-radius: 20px; background-color: rgba(78, 77, 80, 0.5); box-shadow: 4px 6px 8px grey;">
                                <div class="card-body">
                                <h6 class="card-title">Estudia:</h6>
                                    <a href="#" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;" class="card-link">Diseño Grafico</a>
                                </div>
                            </div>
                        </div>

                        <div class="col" style="border-radius: 20px; margin-top:30px;">
                            <div class="card" style="border-radius: 20px; background-color: rgba(78, 77, 80, 0.5); box-shadow: 4px 6px 8px grey;">
                                <div class="card-body">
                                <h6 class="card-title">Estudia:</h6>
                                    <a href="#" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;" class="card-link">Desarrollo Web</a>
                                </div>
                            </div>
                        </div>

                        <div class="col" style="border-radius: 20px; margin-top:30px;">
                            <div class="card" style="border-radius: 20px; background-color: rgba(78, 77, 80, 0.5); box-shadow: 4px 6px 8px grey;">
                                <div class="card-body">
                                <h6 class="card-title">Estudia:</h6>
                                    <a href="#" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;" class="card-link">Ingles</a>
                                </div>
                            </div>
                        </div>

                        <div class="col" style="border-radius: 20px; margin-top:30px;">
                            <div class="card" style="border-radius: 20px; background-color: rgba(78, 77, 80, 0.5); box-shadow: 4px 6px 8px grey;">
                                <div class="card-body">
                                <h6 class="card-title">Estudia:</h6>
                                    <a href="#" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;" class="card-link">Publicidad Digital</a>
                                </div>
                            </div>
                        </div>

                        <div class="col" style="border-radius: 20px; margin-top:30px;">
                            <div class="card" style="border-radius: 20px; background-color: rgba(78, 77, 80, 0.5); box-shadow: 4px 6px 8px grey;">
                                <div class="card-body">
                                <h6 class="card-title">Estudia:</h6>
                                    <a href="#" style="color: #ff0000b5;text-shadow: 7px 3px 6px #222;" class="card-link">Videojuegos</a>
                                </div>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>

    </main>

    <?php include('includes/footer.php'); ?>
</body>

</html><file_sep>/delete_curso.php
<?php
include("db.php");

if(isset($_GET['id'])) {
  $id = $_GET['id'];
  $query = "DELETE FROM cursos WHERE id = $id"; //DELETE FROM `cursos` WHERE `cursos`.`id` = 15
  $result = mysqli_query($conn, $query);
  if(!$result) {
    die("Query Failed.");
  }
  header('Location: cursos_mostrar.php');
}
?><file_sep>/edit_estudiante.php
<?php
include("db.php");
$nombre = '';
$correo= '';
$contraseña= '';

if  (isset($_GET['id'])) {
  $id = $_GET['id'];
  $query = "SELECT * FROM estudiantes WHERE id=$id";
  $result = mysqli_query($conn, $query);
  if (mysqli_num_rows($result) == 1) {
    $row = mysqli_fetch_array($result);
    $nombre = $row['nombre'];
    $correo = $row['correo'];
    $contraseña = $row['contraseña'];
  }
}

if (isset($_POST['update'])) {
  $id = $_GET['id'];
  $nombre= $_POST['nombre'];
  $correo = $_POST['correo'];
  $contraseña = $_POST['contraseña'];

  $query = "UPDATE estudiantes set nombre = '$nombre', correo = '$correo', contraseña = <PASSWORD>' WHERE id=$id";
  mysqli_query($conn, $query);
  $_SESSION['message'] = 'Task Updated Successfully';
  $_SESSION['message_type'] = 'warning';
  header('Location: estudiante.php');
}

?>
<?php include('includes/header.php'); ?>
<div class="container p-4">
  <div class="row">
    <div class="col-md-4 mx-auto">
      <div class="card card-body">
      <form action="edit_estudiante.php?id=<?php echo $_GET['id']; ?>" method="POST">
        <div class="form-group">
          <input name="nombre" type="text" class="form-control" value="<?php echo $nombre; ?>" placeholder="Update Title">
        </div>
        <div class="form-group">
          <input name="correo" type="text" class="form-control" value="<?php echo $correo; ?>" placeholder="Update Title">
        </div>
        <div class="form-group">
          <input name="contraseña" type="text" class="form-control" value="<?php echo $contraseña; ?>" placeholder="Update Title">
        </div>
        <button class="btn-success" name="update">
          Actualizar
        </button>
      </form>
      </div>
    </div>
  </div>
</div>
<?php include('includes/footer.php'); ?>
<file_sep>/registrarse.php
<?php include('includes/headerdos.php'); ?>

<main class="container p-4">
    <div class="row">
        <div class="col-md-4">

            <?php if (isset($_SESSION['message2'])) { ?>
            <div class="alert alert-<?= $_SESSION['message_type2']?> alert-dismissible fade show" role="alert">
                <?= $_SESSION['message2']?>
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <?php session_unset(); } ?>

            <!-- Agregar estudiante -->
            <div class="card card-body" style="position: relative; left: 110%;top: 50%; border-radius: 20px; box-shadow: 4px 6px 8px grey;">
                <form action="save_registro.php" method="POST">
                    <div class="form-group">
                        <label for="exampleInputEmail1">Nombre</label>
                        <input type="text" style="box-shadow: 4px 6px 8px grey;" name="nombre" class="form-control rounded-pill" placeholder="Nombre" autofocus>
                    </div>
                    <div class="form-group">
                    <label for="exampleInputEmail1">Email</label>
                        <input type="text" style="box-shadow: 4px 6px 8px grey;" name="Email" class="form-control rounded-pill" placeholder="Correo" autofocus>
                    </div>
                    <div class="form-group">
                    <label for="exampleInputEmail1">Contraseña</label>
                        <input type="password" style="box-shadow: 4px 6px 8px grey;" name="contraseña" class="form-control rounded-pill" placeholder="Contraseña"
                            autofocus>
                    </div>
                    <input type="submit" name="guardar" style="box-shadow: 4px 6px 8px grey;" class="btn btn btn-outline-dark btn-block rounded-pill" value="Aceptar">
                    <a class="" style="display: flex; justify-content: center; align-items: center; color:black; margin-top: 20px;" href="index.php">INICIA SESION</a>
                </form>
            </div>
        </div>
    </div>
    </div>
</main>

<?php include('includes/footer.php'); ?><file_sep>/cursos_mostrar.php
<?php include("db.php"); ?>

<?php include('includes/header.php'); ?>

<!-- Mostrar Mis Cursos Registrados -->
<main class="container p-4">

    <div class="col" style="margin-top:20px;">
        <div class="col-md-12">
            <div class="card" style="width: 100%; border-radius:20px;">

                <div class="card-body">
                    <form action="save_curso.php" method="POST">
                        <!-- nombre -->
                        <div class="form-group">
                            <?php
                                $query = "SELECT cursos.nombre FROM usuarios INNER JOIN cursos ON usuarios.id = cursos.usuario";
                                $result_student = mysqli_query($conn, $query);    
                                while($row = mysqli_fetch_assoc($result_student)) { ?>
                            <ol style="text-align: center;">
                                <a class="card-title" style="color: black;"><?php echo $row['nombre']; ?></a>
                                <br>
                                <!-- <input type="submit" name="delete_curso" class="btn btn-outline-dark rounded-pill"
                                    value="Eliminar"> -->

                                <!-- <a href="delete_curso.php?id=<?php echo $row['id']?>" class="btn btn-danger">
                                    <i class="far fa-trash-alt"></i>
                                </a> -->
                                <br>
                            </ol>
                            <?php } ?>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

</main>

<?php include('includes/footer.php'); ?><file_sep>/cursos_obtener.php
<?php include("db.php"); ?>
<?php include('includes/header.php'); ?>

<main class="container p-4">
    <div class="row row-cols-3">
        <div class="col" style="margin-top:20px;">
            <div class="col-md-4">
                <div class="card" style="width: 18rem; border-radius:20px; box-shadow: 10px 10px 5px grey;">
                    <img src="https://img-b.udemycdn.com/course/240x135/1075334_8b5f_4.jpg?secure=Hrs-YOFwX2SAaY81iIW-2Q%3D%3D%2C1606563455"
                        class="card-img-top" alt="..." style="border-radius:20px;">
                    <div class="card-body">
                        <form action="save_curso.php" method="POST">
                            <!-- nombre -->
                            <div class="form-group">
                                <input type="hidden" name="nombre" class="form-control" value="Angular: Desde cero a experto + 15 proyectos jajajaja"
                                    autofocus>
                                <input type="hidden" name="usuario" value="1">
                            </div>
                            <h5 class="card-title">Angular: Desde cero a experto + 15 proyectos jajajaja</h5>
                            <p class="card-text">$ 50.000</p>
                            <input type="submit" style="box-shadow: 4px 6px 8px grey;" name="save_curso" class="btn btn-outline-dark rounded-pill" value="Obtener">
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <div class="col" style="margin-top:20px;">
            <div class="col-md-4">
                <div class="card" style="width: 18rem; border-radius:20px; box-shadow: 10px 10px 5px grey;">
                    <img src="https://img-a.udemycdn.com/course/240x135/782428_b5cf_4.jpg?_UZmRyG2CSoNyNmgUBa1lkncytFkXWOuaK3z6EpDubl8_7gdSwmDLtg6UkKfxCw0LHa3-PUxEqaxvMk4Lzar27cFNec2uLLAAqpA-PHVhIG3G_9H1IHImvhgHxRA5H0"
                        class="card-img-top" alt="..." style="border-radius:20px;">
                    <div class="card-body">
                        <form action="save_curso.php" method="POST">
                            <!-- nombre -->
                            <div class="form-group">
                                <input type="hidden" name="nombre" class="form-control" value="Diseño Web Profesional El Curso Completo, Práctico y desde 0"
                                    autofocus>
                                <input type="hidden" name="usuario" value="1">
                            </div>
                            <h5 class="card-title">Diseño Web Profesional El Curso Completo, Práctico y desde 0</h5>
                            <p class="card-text">$ 60.000</p>
                            <input type="submit" style="box-shadow: 4px 6px 8px grey;" name="save_curso" class="btn btn-outline-dark rounded-pill" value="Obtener">
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <div class="col" style="margin-top:20px;">
            <div class="col-md-4">
                <div class="card" style="width: 18rem; border-radius:20px; box-shadow: 10px 10px 5px grey;">
                    <img src="https://img-b.udemycdn.com/course/240x135/672600_1def_7.jpg?secure=Bvr-7xuIGIXFGuW0F_q1oQ%3D%3D%2C1606554269"
                        class="card-img-top" alt="..." style="border-radius:20px;">
                    <div class="card-body">
                        <form action="save_curso.php" method="POST">
                            <!-- nombre -->
                            <div class="form-group">
                                <input type="hidden" name="nombre" class="form-control" value="PHP 7 y MYSQL: El Curso Completo, Práctico y Desde Cero !"
                                    autofocus>
                                <input type="hidden" name="usuario" value="1">
                            </div>
                            <h5 class="card-title">PHP 7 y MYSQL: El Curso Completo, Práctico y Desde Cero !</h5>
                            <p class="card-text">$ 100.000</p>
                            <input type="submit" style="box-shadow: 4px 6px 8px grey;" name="save_curso" class="btn btn-outline-dark rounded-pill" value="Obtener">
                        </form>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="col" style="margin-top:20px;">
            <div class="col-md-4">
                <div class="card" style="width: 18rem; border-radius:20px; box-shadow: 10px 10px 5px grey;">
                    <img src="https://img-b.udemycdn.com/course/240x135/1509816_dff8.jpg?secure=Nb3DfVpx1AFQdolS_1M1oA%3D%3D%2C1606568258"
                        class="card-img-top" alt="..." style="border-radius:20px;">
                    <div class="card-body">
                        <form action="save_curso.php" method="POST">
                            <!-- nombre -->
                            <div class="form-group">
                                <input type="hidden" name="nombre" class="form-control" value="JavaScript Moderno Guía Definitiva Construye +15 Proyectos"
                                    autofocus>
                                <input type="hidden" name="usuario" value="1">
                            </div>
                            <h5 class="card-title">JavaScript Moderno Guía Definitiva Construye +15 Proyectos</h5>
                            <p class="card-text">$ 100.000</p>
                            <input type="submit" style="box-shadow: 4px 6px 8px grey;" name="save_curso" class="btn btn-outline-dark rounded-pill" value="Obtener">
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <div class="col" style="margin-top:20px;">
            <div class="col-md-4">
                <div class="card" style="width: 18rem; border-radius:20px; box-shadow: 10px 10px 5px grey;">
                    <img src="https://img-a.udemycdn.com/course/240x135/1756340_0543_4.jpg?Fty2AMou-pxDnsuvoODvS4njNb6l31HWLao7DrpI7isJUaaN0DDORrQTfWxmPQ3S4f-Zag0KzD27enZiRpPWcywBVK_8G8F87PBALTuLpilNYUcV3_U7Vwxk2B9fZaxf"
                        class="card-img-top" alt="..." style="border-radius:20px;">
                    <div class="card-body">
                        <form action="save_curso.php" method="POST">
                            <!-- nombre -->
                            <div class="form-group">
                                <input type="hidden" name="nombre" class="form-control" value="React - La Guía Completa: Hooks Context Redux MERN +15 Apps"
                                    autofocus>
                                <input type="hidden" name="usuario" value="1">
                            </div>
                            <h5 class="card-title">React - La Guía Completa: Hooks Context Redux MERN +15 Apps</h5>
                            <p class="card-text">$ 100.000</p>
                            <input type="submit" style="box-shadow: 4px 6px 8px grey;" name="save_curso" class="btn btn-outline-dark rounded-pill" value="Obtener">
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <div class="col" style="margin-top:20px;">
            <div class="col-md-4">
                <div class="card" style="width: 18rem; border-radius:20px; box-shadow: 10px 10px 5px grey;">
                    <img src="https://img-a.udemycdn.com/course/240x135/1467412_94b5_11.jpg?eiHQ5t362GOdfglRrwjuPo-DruynFMTmSUrmHJUJ36kitzyKT_M9DJQWKmyfvMZnXN1vGeDuo5sS_8werq2QfcIoRG4r586CnSlZn3DGJNzOd5KR7kdioiyqtgYX2RT6Cw"
                        class="card-img-top" alt="..." style="border-radius:20px;">
                    <div class="card-body">
                        <form action="save_curso.php" method="POST">
                            <!-- nombre -->
                            <div class="form-group">
                                <input type="hidden" name="nombre" class="form-control" value="Crea sistemas POS Inventarios y ventas con PHP 7 y AdminLTE"
                                    autofocus>
                                <input type="hidden" name="usuario" value="1">
                            </div>
                            <h5 class="card-title">Crea sistemas POS Inventarios y ventas con PHP 7 y AdminLTE</h5>
                            <p class="card-text">$ 100.000</p>
                            <input type="submit" style="box-shadow: 4px 6px 8px grey;" name="save_curso" class="btn btn-outline-dark rounded-pill" value="Obtener">
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<?php include('includes/footer.php'); ?><file_sep>/save_curso.php
<?php

include('db.php');

if (isset($_POST['save_curso'])) {
  $nombre = $_POST['nombre'];
  $usuario = $_POST['usuario'];
  $query = "INSERT INTO cursos(nombre, usuario) VALUES ('$nombre', '$usuario')";
  $result = mysqli_query($conn, $query);
  if(!$result) {
    die("Query Failed.");
  }

  $_SESSION['message_is'] = 'Tarea Creada';
  $_SESSION['message_type_is'] = 'success';
  header('Location: cursos_obtener.php');

}

?><file_sep>/validar.php
<?php
    include('db.php');

    // if(isset($_POST['email']) && isset($_POST['contraseña'])){
    //     $email = $_POST['email'];
    //     $contraseña= $_POST['contraseña'];

    //     $query = "SELECT * FROM estudiantes where correo = '$email' and contraseña = '$contraseña'";
    //     $result = mysqli_query($conn, $query);

    //     $filas = mysqli_num_rows($result);

    //     if(!$filas){
            
    //         header('Location: index_2.php');
            
    //     }else{
    //         // $_SESSION['login'] = $filas;
    //         // header('Location: index_2.php');
    //         echo('Usuario o contraseña son incorrectos');
    //     }
    // }

    // if(isset($_POST['email']) && isset($_POST['contraseña'])){
    //     $correo = $_POST['email'];
    //     $contraseña = $_POST['contraseña'];
    
    //     $db = new Database();
    //     // $query = "SELECT * FROM estudiantes where nombre = '$nombre' and contraseña = '$<PASSWORD>'";
    //     $query = $db->connect()->prepare("SELECT * FROM estudiantes where correo = '$correo' and contraseña = '$contr<PASSWORD>'");
    //     $query->execute(['correo'=>$correo, 'contraseña'=>$contraseña]);
    
    //     $row = $query->fetch(PDO::FETCH_NUM);
    //     if($row == true){
    //         //validar rol
    //     }else{
    //         echo('Usuario o contraseña son incorrectos');
    //     }
    // }

    // mysqli_free_result($result);
    // mysqli_close($conn);

    //-------------------------------------------------------------------

    
if (isset($_GET['cerrar_sesion'])){
    session_unset();

    session_destroy();
}

if (isset($_SESSION['rol'])){
    switch($_SESSION['rol']){
        case 1:
            header('location: index_estudiante.php');
        break;

        case 2:
            header('location: index_admin.php');
        break;

        default:
    }
}


// if(isset($_POST['correo']) && isset($_POST['contraseña'])){
//     $correo = $_POST['correo'];
//     $contraseña = $_POST['contraseña'];

//     $db = new Database();
//     $query = $db->connect()->prepare("SELECT * FROM usuarios where correo = '$correo' and contraseña = '$contraseña'");
//     $query->execute(['correo'=>$correo, 'contraseña'=>$contraseña]);

//     $row = $query->fetch(PDO::FETCH_NUM);
//     if($row == true){
//         //validar 
//         $rol = $row[3];
//         $_SESSION['rol'] = $rol;
//         switch($_SESSION['rol']){
//             case 1:
//                 header('location: index_estudiante.php');
//             break;
    
//             case 2:
//                 header('location: index_admin.php');
//             break;
    
//             default:
//         }
//     }else{
//         echo('Usuario o contraseña son incorrectos');
//     }
// }

if(isset($_POST['correo']) && isset($_POST['contraseña'])){
    $email = $_POST['correo'];
    $contraseña= $_POST['<PASSWORD>'];

    $query = "SELECT * FROM usuarios where correo = '$email' and contraseña = '$contr<PASSWORD>'";
    $result = mysqli_query($conn, $query);

    $filas = mysqli_num_rows($result);
    // $row = $query->fetch(PDO::FETCH_NUM);
    if($filas == true){
        // header('Location: index_2.php');
        $rol = $filas;
        $_SESSION['rol'] = $rol;
        
        switch($_SESSION['rol']){
            case 1:
                header('location: pagina_inicio.php');
            break;
    
            case 2:
                header('location: index_admin.php');
            break;
    
            default:
        }
    }else{

        echo('Usuario o contraseña son incorrectos');
    }
}



    
    // <!-- ENVIO DE COOREO ELECTRONICO -->
    require 'src/Exception.php';
    require 'src/PHPMailer.php';
    require 'src/SMTP.php';

    $correo = $_POST["correo"];
    $mensaje = $_POST["mensaje"];
 
    $mail = new PHPMailer\PHPMailer\PHPMailer(true);

    try {
        //Server settings
        $mail->SMTPDebug = 0;                                       // Enable verbose debug output
        $mail->isSMTP();                                            // Set mailer to use SMTP
        $mail->Host       = 'smtp.gmail.com';  // Specify main and backup SMTP servers
        $mail->SMTPAuth   = true;                                   // Enable SMTP authentication
        $mail->SMTPSecure = 'tls';                                  // Enable TLS encryption, `ssl` also accepted
        $mail->Port       = 587;                                    // TCP port to connect to
    
        
        //https://support.google.com/mail/answer/185833?hl=es-419 POR ACA INGRESAN PARA CREAR LA CLAVE DE LA APP
        $mail->Username   = '<EMAIL>';                     // SMTP username
        $mail->Password   = '<PASSWORD>';                               // SMTP password
  
        //DESDEEE -->
        $mail->setFrom('<EMAIL>', '<NAME>'); 
        
        //La siguiente linea, se repite N cantidad de veces como destinarios tenga
        $mail->addAddress($correo, $correo);     // Add a recipient
   
        
        // Content
        $mail->isHTML(true);                                  // Set email format to HTML
        $mail->Subject = 'Mensaje automatico';
        $mail->Body    = $mensaje;
        $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
        $mail->send();

        $data["res"] = 'Message has been sent';

    } catch (Exception $e) {
        $data["res"] = 'Error';
        echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
    }

    echo json_encode($data);
?><file_sep>/index.php
<?php include("db.php");

session_start();


?>

<?php include('includes/headerdos.php'); ?>

<main class="container p-4">
    <div class="row">
        <div class="col-md-4">
            <div class="card card-body" style="position: relative; left: 110%;top: 50%; border-radius: 20px; box-shadow: 4px 6px 8px grey;">
                <div class="sesion">

                    <form action="validar.php" method="POST">
                        <div class="form-group">
                            <label for="exampleInputEmail1">Email</label>
                            <input type='text' style="box-shadow: 4px 6px 8px grey;" class="form-control rounded-pill" placeholder="Email" name="correo">
                            <input type='hidden' class="form-control" name="mensaje" value="Has iniciado sesión en HugoLearn">
                        </div>
                        <div class="form-group">
                            <label for="exampleInputPassword1">Contraseña</label>
                            <input type="<PASSWORD>" style="box-shadow: 4px 6px 8px grey;" class="form-control rounded-pill" placeholder="<PASSWORD>" name="contraseña">
                        </div>
                        <input type="submit" name="ini_sesion" style="box-shadow: 4px 6px 8px grey;" class="btn btn btn-outline-dark btn-block rounded-pill" value="Aceptar">
                        <!-- <button type="submit" name="ini_sesion" class="btn btn-primary">Aceptar</button> -->
                        <a class="" style="display: flex; justify-content: center; align-items: center; color:black; margin-top: 20px;" href="registrarse.php">REGISTRARSE</a>
                    </form>

                </div>
            </div>
        </div>
    </div>
</main>

<?php include('includes/footer.php'); ?><file_sep>/imprimir.php
<?php
header("Content-Type:   application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=abc.doc");  //File name extension was wrong
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);


  $mysqli = new mysqli("localhost", "root", "", "php_mysql_crud");
  if ($mysqli->connect_errno) {
      echo "Falló la conexión con MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
  }

  $resultado = $mysqli->query("SELECT * FROM `task`");

  if($resultado){

    echo "<table border='1'>";
      echo "<tr>
          <td>Id</td>
          <td>Titulo</td>
          <td>Descripcion</td>
          <td>Fecha</td>
        </tr>
      ";
 

    while ($itemTemp = $resultado->fetch_assoc()) {
      echo "<tr>
              <td>".$itemTemp['id']."</td>
              <td>".$itemTemp['title']."</td>
              <td>".$itemTemp['description']."</td>
              <td>".$itemTemp['created_at']."</td>
            </tr>
          ";
    }

    echo "</table>";
  }else{
    echo "Falló sql: (" . $mysqli->errno . ") " . $mysqli->error;
  
  }



?><file_sep>/index_2.php
<?php include("db.php"); ?>

<?php include('includes/header.php'); ?>

<main class="container p-4">
    <div class="row rounded-pill" style="display: flex; justify-content: center; align-items: center;">
        <div class="col-md-4">
            <!-- MESSAGES -->

            <?php if (isset($_SESSION['message'])) { ?>
            <div class="alert alert-<?= $_SESSION['message_type']?> alert-dismissible fade show" role="alert">
                <?= $_SESSION['message']?>
                <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <?php session_unset(); } ?>

            <!-- ADD TASK FORM -->
            <div class="card card-body" style="border-radius:20px; box-shadow: 4px 6px 8px grey">
                <form action="save_task.php" method="POST">
                    <div class="form-group">
                        <label for="exampleInputEmail1">Titulo</label>
                        <input type="text" style="box-shadow: 4px 6px 8px grey;" name="title" class="form-control rounded-pill" placeholder="Titulo" autofocus>
                    </div>
                    <div class="form-group">
                        <label for="exampleInputEmail1">Descripcion</label>
                        <textarea name="description" rows="1" style="box-shadow: 4px 6px 8px grey;" class="form-control rounded-pill" placeholder="Descripcion"></textarea>
                    </div>
                    <input type="submit" name="save_task" style="box-shadow: 4px 6px 8px grey;" class="btn btn btn-outline-dark btn-block rounded-pill" value="Guardar Tarea">
                </form>
            </div>
        </div>

        <!-- Mostrar task en tabla -->
        <div class="col-md-12 ver-tarea rounded-pill" style="margin-top: 20px">
            <table class="table table-bordered" style="border-radius:20px;">
                <thead class="thead-dark" style="border-radius: 20px">
                    <tr>
                        <th>Titulo</th>
                        <th>Descripcion</th>
                        <th>Fecha</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                  <?php
                    $query = "SELECT * FROM task";
                    $result_tasks = mysqli_query($conn, $query);    

                    while($row = mysqli_fetch_assoc($result_tasks)) { ?>
                    <tr>
                        <td><?php echo $row['title']; ?></td>
                        <td><?php echo $row['description']; ?></td>
                        <td><?php echo $row['created_at']; ?></td>
                        <td>
                            <a href="edit.php?id=<?php echo $row['id']?>" class="btn btn-secondary">
                                <i class="fas fa-marker"></i>
                            </a>
                            <a href="delete_task.php?id=<?php echo $row['id']?>" class="btn btn-danger">
                                <i class="far fa-trash-alt"></i>
                            </a>
                        </td>
                    </tr>
                  <?php } ?>
                </tbody>
            </table>
            <a type="submit" href="imprimir.php" style="box-shadow: 4px 6px 8px grey;" class="btn btn-outline-dark rounded-pill">Imprimir Tareas</a>
        </div>
    </div>
</main>

<?php include('includes/footer.php'); ?>