Note that there are some explanatory texts on larger screens.

plurals
  1. POreply to message: update mysql table where id matches?
    primarykey
    data
    text
    <p>I have a messaging system on my site that allows users to send and receive messages to each other. </p> <p>the bit I am working on now is if a user sends another user a message and the user reads this message, they can reply to it.</p> <p>at the moment my html form is set up with the message content echoing out in the text area, the user can then remove this content from the text area and re type what they want in it.</p> <p>then as soon as they hit submit this then should go to message_reply.php and this should insert the new message content where the original message id exists and send it back to the user it came from so this means again update message content where the id, user_to_id and user_from_id is matched and it should insert the original subject with a :reply suffix and also update 'read_message' and set the enum value from 1 back to 0 (as in unread). </p> <p>I'm struggling with this because I'm new to php and mysql. please can someone show me what I need to do.</p> <p>my mysql table is called 'ptb_messages' and its laid out like so:</p> <pre><code>id | from_user_id(the person who sent msg) | to_user_id (recipient) | content | date_sent | read_message | deleted_to | deleted_from | </code></pre> <p>here's my html form:</p> <pre><code>&lt;form action="message_reply.php?to=&lt;?php echo "$profile_id"; ?&gt;" method="post"&gt; &lt;textarea name="textarea" id="textarea"&gt; &lt;?php echo "{$message['content']}"; ?&gt; &lt;/textarea&gt; &lt;?php } ?&gt; &lt;input type="image" src="assets/img/icons/email_send.png" width="50" height="34" name="send_button" id="send_button"&gt; &lt;/form&gt; </code></pre> <p>mysql function (message_reply.php)</p> <pre><code>&lt;?php //We check if the form has been sent if(isset($_POST['textarea'])) { $textarea = $_POST['textarea']; //We remove slashes depending on the configuration if(get_magic_quotes_gpc()) { $textarea = stripslashes($textarea); } //We check if all the fields are filled if($_POST['textarea']!='') { $sql = "UPDATE ptb_messages SET (id, from_user_id, to_user_id, textarea) VALUES (NULL, '".$_SESSION['user_id']."', '".$message['from_user_id']."', '".$textarea."');"; mysql_query($sql, $connection); echo "&lt;div class=\"infobox1\"&gt;The message has successfully been sent.&lt;/div&gt;"; } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload