You don't need a separate form for each article, you don't need a hidden input, and you don't need JavaScript. Just use a button instead of an input like the other answer suggested. Any of those buttons will submit the form if they're clicked, and $_POST['id']
will have the value of the button that was clicked.
is different than
because it's not a self-closing tag. With an
, the value is the button text. But with a
, you can give it a value, and then put the text you want it to have between the tags.
Here's an example based on your code.
Unrelated to the question, I also fixed the repeated csrf_field and merged the two classes on the button.