php - Identifying which button has triggered Form Post -


i have page has form such this:

<form method="post">     <input name="data1" type="hidden" value="x">     <input name="data2" type="hidden" value="y">      <button name="button1" formaction="page1.php">do something</button>     <button name="button2" formaction="page2.php">do else</button>  </form> 

to tidy consolidate page1 , page2 1 need able identify button fired it. have this:

<form method="post">     <input name="data1" type="hidden" value="x">     <input name="data2" type="hidden" value="y">      <button name="button1" formaction="page.php">do something</button>     <button name="button2" formaction="page.php">do else</button> </form> 

is possible page.php know button fired it?

there's nothing change in <form /> here, thour php script know button has been clicked name attribute :

<?php if (isset($_post['button1'])) {     echo 'button1 has been clicked!'; } else if (isset($_post['button2'])) {     echo 'button2 has been clicked!'; } 

Comments

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

sql server - Cannot query correctly (MSSQL - PHP - JSON) -