It is essential to pass a variable in the delete link. You can either pass the variable (?php echo $contact['name']; ?) in a hidden field or pass it in the URL.
Step 1
Replace the original code:
<td class="contact-delete"> <form action='delete.php' method="post"> <input type="hidden" name="name" value=""> <input type="submit" name="submit" value="Delete"> </form> </td>
Step 2
With the following code:
<td class="contact-delete"> <form action='delete.php?name="<?php echo $contact['name']; ?>"' method="post"> <input type="hidden" name="name" value="<?php echo $contact['name']; ?>"> <input type="submit" name="submit" value="Delete"> </form> </td>
The above is the detailed content of How to Pass a Variable in a Delete Link for PHP Forms?. For more information, please follow other related articles on the PHP Chinese website!