Warning: Undefined array key "buscar"

267 views
Skip to first unread message

Juan Miguel Vasquez Perez

unread,
May 4, 2022, 7:58:18 PM5/4/22
to PHP Latinoamérica
Buenas, 

soy nuevo en PHP y cuando ejecuto mi aplicación me da este error


Warning: Undefined array key "buscar" in C:\xampp\htdocs\buscador\index.php on line 26

Warning: Undefined array key "buscar" in C:\xampp\htdocs\buscador\index.php on line 26
Este es mi codigo:


<?php include("db.php"); ?>
<?php include("header.php"); ?>

<div class="container mt-5">
    <div class="col-12">
 
        <div class="row">
        <div class="col-12 grid-margin">
        <div class="card">
        <div class="card-body">
        <h4 class="card-title">Buscador</h4>


        <form action="index.php" method="POST" >
        <div class="col-12 row">
        <div class="col-11">
        <input type="text" class="form-control" name="buscar" placeholder="Escriba la referencia">    
        </div>
       <div class="col-md-1">
       <input type= "submit" class="btn btn-success" value="Buscar">
       </div>
       </div>

       <?php
                                           
       $sql= $con->query("SELECT * FROM plan WHERE responsable LIKE '%".$_POST['buscar']."%' OR descripcion LIKE '%".$_POST['buscar']."%'   ");
       $numeroSql = mysqli_num_rows($sql);
       
       ?>
       <p style="font-weight: bold; color:green;"><i class="mdi mdi-file-document"></i> <?php echo $numeroSql; ?> Resultados encontrados</p>
       </form>


                <div class="table-responsive">
                <table class="table">
                                                        <thead>
                <tr style="background-color: #00695c; color:#FFFFFF;">
                <th style=" text-align: center;"> Fecha Inicio </th>
                <th style=" text-align: center;"> Asunto </th>
                <th style=" text-align: center;"> Accion </th>
                <th style=" text-align: center;"> Responsable </th>
                <th style=" text-align: center;"> Fecha Cierre </th>
                <th style=" text-align: center;"> Status</th>
                                                                </tr>
                                                        </thead>
                                <tbody>
            <?php while ($rowSql = mysqli_fetch_assoc($sql)){ ?>
                                               
                                                <tr>
           <td style="text-align: center;"><?php echo $rowSql["date_start"]; ?></td>
          <td style="text-align: center;"><?php echo $rowSql["asunto"]; ?></td>
         <td style="text-align: center;"><?php echo $rowSql["descripcion"]; ?></td>
         <td style=" text-align: center;"><?php echo $rowSql["responsable"]; ?></td>
         <td style=" text-align: center;"><?php echo $rowSql["date_close"]; ?></td>
         <td style=" text-align: center;"><?php echo $rowSql["status"]; ?></td>
                                                                </tr>
                                               
                                                <?php } ?>
                                                        </tbody>
                                                </table>
                                        </div>


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


    </div>
</div>
<?php include("footer.php"); ?>

Le agradeceria mil si me ayudaran a solucionarlo

Saludos.
Reply all
Reply to author
Forward
0 new messages