I need to send an id to the page, I got to this solution:

<? $post['id'] = 1; ?> 

<form method="POST" action="./post.php"> <input type="submit" class="btn btn-info btn-sm" name="<?echo $post['id'];?>" value="Прочесть польностью"/> </form>

Then I get id in this way:

$id_post = array_keys($_POST)[0];

I get such an array

Array ( [1] => Прочесть польностью )

In the array, my value is $post['id'] as the key and the button's label as value.

How can I get a $_POST this format?

Array ( [id] => 1 )

    2 answers 2

     <form method="POST" action="./post.php"> <input type="submit" class="btn btn-info btn-sm" name="<?PHP echo $post['id'];?>" value="Прочитать польностью"/>`</form>` 

    PHP tag forgot

    • There is such a thing that I do not need to prescribe php. The code is working, I am sending $ post ['id'], then it is in the $ _POST array as the key - Yura Petrov

    Found the answer, who can come in handy

     <form method="POST" action="./post.php"> <input type="hidden" name="id" value = "<?echo $post['id'];?>"> <input type="submit" class="btn btn-info btn-sm" name="<?echo $post['id'];?>" value="Читати повністью"/> </form> 

    Array ( [1] => Читати повністью [id] => 1 )