Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

138
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!