Home > Database > Mysql Tutorial > body text

How to Pass a Variable in a Delete Link for PHP Forms?

Susan Sarandon
Release: 2024-10-28 07:41:01
Original
167 people have browsed it

How to Pass a Variable in a Delete Link for PHP Forms?

How to add a delete button to a PHP form that will delete a row from a MySQL table

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=&quot;contact-delete&quot;>
                <form action='delete.php' method=&quot;post&quot;>
                        <input type=&quot;hidden&quot; name=&quot;name&quot; value=&quot;&quot;>
                        <input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Delete&quot;>
                </form>
        </td>
Copy after login

Step 2
With the following code:

        <td class=&quot;contact-delete&quot;>
                <form action='delete.php?name=&quot;<?php echo $contact['name']; ?>&quot;' method=&quot;post&quot;>
                        <input type=&quot;hidden&quot; name=&quot;name&quot; value=&quot;<?php echo $contact['name']; ?>&quot;>
                        <input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Delete&quot;>
                </form>
        </td>
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!