简体   繁体   中英

two submit buttons in one form of type 'image'

I have a form in PHP with two submit buttons of type 'image'. How do I know which button is clicked?

Code:

<?php

echo ("

    <form action='WijzigSession.php' method='POST'>
    <td><input class= 'nummers' type='number' name='aantal' value=".$_SESSION['producten'][$i]['aantal']." min='1' max='20'>
    <input name='refresh' class='buttons' type='image' src='img/refresh.png'</a>
    <input name='delete' class='buttons' type='image' src='img/delete.png'</a>
    <input type='hidden' name='id' value='$i'>
    </form></td>
    <td>&euro; ".$_SESSION['producten'][$i]['prijs']."</td>

    ");

?>

Just try:

if(isset($_POST['refresh_x'])) { //you can potentially even check for '$_POST['refresh_y']'
    // refresh is clicked
}

if(isset($_POST['delete_x'])) {
    // delete is clicked
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM