Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

148
Vistas
Is there a way, to send the value of a button to different pages in PHP?

I am working on project and came across the problem: When i click a button on the e.g. //website/manageuser.php I want the value of the button in the //website/edituser.php

I tried using the <value> tag in a button but failed. I wasn't able to manage to transfer the value through the files.

My manageuser.php looks like this: Test

After i press the e.g. "Delete" button, i get forwarded to the /deleteuser.php where I want to print the value behind the button. Unfortunatly, it isn't working with a StackOverflow Javascript script.

Image of my /deleteuser.php:

enter image description here

Code of the important part of manageuser.php:

<table>
    <tr>
            
<?php
$query = "select * from users";
$records = mysqli_query($con, $query); 
while($data = mysqli_fetch_array($records)) 
{   
?>
        <th>
            <p/>
<?php
    print($data["full_name"]);
?>                  
            <button type="button" value=" <?php print($data['full_name']) ?>" onclick="window.location.href='./edituser.php'">Edit</button>
            <button type="button" onclick="window.location.href='./deleteuser.php'"> Delete </button> 
        </th>
<?php
}
?>  
    </tr>
</table>

Code of the important part of deleteuser.php:

<!DOCTYPE html>
<html>
   <body>
      
      <script>
         var str1 = document.getElementById("btn").innerHTML;
         var str2 = document.getElementById("btn").value;
         document.write("Button text: "+str1);
         document.write("<br>Button value: "+str2);
      </script>
   </body>
</html>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You don't need the value. Just append the value from $data as a query parameter to the URL.

<button type="button" onclick="window.location.href='./deleteuser.php?id=<?php echo $data['id'] ?>"> Delete </button>

Then in deleteuser.php you can use $_GET['id'].

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda