Reputation: 13
I have two submit buttons in my form. One button for publishing the article immediately and one button for saving the article as a draft. How can I manage through PHP, not JavaScript, to detect which one that was pressed by the user when submitting the form? Appreciate any thoughts.
<button type='submit' name='publish' class='btn btn-success'>Publiser</button>
<button type='submit' name='draft' class='btn btn-success'>Lage som kladd</button>
Upvotes: 1
Views: 136
Reputation: 437336
Check which of the two names is an existing key inside $_POST
:
if(isset($_POST['publish'])) { ... }
else if(isset($_POST['draft'])) { ... }
Upvotes: 10