When making a query I get the number 1 in the input - PHP [closed]

0

My problem is as follows, when I make a query, the number 1 appears in the input automatically, does anyone know why?

Attached image.

Here is the Code - PHP

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

  <form action="buscador.php" method="POST">
  <input type="text" name="palabra" placeholder="buscar aqui.." value="<?php  
  echo(isset($_POST["palabra"])); ?>" oNclick="this.value=''"; />
 <input type="submit" name="buscador" value="Buscar" id="buscar" />
   <style type="text/css">
   #buscar{
    display: none;
  }

 </style>
 </form>

 <?php 

 if(isset($_POST['buscador'])){

 $buscar = $_POST['palabra'];

 if (empty($buscar)){
echo "No se ha ingresado ninguna palabra";
 }
else
{

 $sql = "SELECT * FROM peliculas WHERE nombre LIKE '%$buscar%'";
 $result = $conexion->query($sql);

 $total = mysqli_num_rows($result);

 if ($row = mysqli_fetch_array($result)) {

  echo "Resultados para: $buscar";
  ?>
 <br>
<?php

do {
 ?>
 <br>
 <br>
  <a href="<?php echo $row['link'] ?>">(nombre: <?php echo $row['nombre']; ?>)</a>

<?php
}
  while ($row = mysqli_fetch_array($result));
 }
else
 {
 echo "No se encontraron resultados para: $buscar";
 }
 }
 }
?>
    
asked by kyle 30.05.2017 в 20:26
source

1 answer

1

Problem:

echo(isset($_POST["palabra"])) 

returns true, which is printed as 1.

Solution:

echo(isset($_POST["palabra"]) ? $_POST["palabra"]:'');
    
answered by 30.05.2017 / 20:30
source