Jump to content

POST name


Porl123

Recommended Posts

I've got an inbox page on my site where all messages are shown in php, from mysql. Attached to each message is an invisible textarea and submit button, where you can instantly reply to a message, but because I can't use a hidden input to post the ID to the php procedure because it interferes with another <form> tag I have going around all the messages for the delete selected messages button, so I was wondering if it's possible to put <textarea name="message[<? $id; ?>]">, so the php knows which message it's replying to. Is this possible? If so, could you give me a brief example?

 

Any help is appreciated. Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/142520-post-name/
Share on other sites

I haven't really got much to paste. Just wondering if that'd work

Sort of. To access the elements you would do:

 

<?php

$textAreas = $_POST['message'];

foreach ($textAreas as $id => $message) {
     echo "ID: $id has $message for a message.<br />";
}
?>

<textarea name="message[<?php echo $id; ?>]">

 

Also notice I changed the <? $id; ?> portion too.

 

Link to comment
https://forums.phpfreaks.com/topic/142520-post-name/#findComment-746840
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.