It would first depend on your current system design. Do you already use Sessions or are you using some other form of activity?
If you are familiar with the $_POST SUBMIT option then keep using this and just add the message_id that the user is replying as a hidden field so your reply script knows to grab the last contents from the corrent message and give option to edit it etc.
Regards the tickbox, it would depend on whether you want the user to be able to edit the previous content before the message is saved or just type their message and have the original message attached after it when they click send etc.
The tickbox was just an idea that I have come accross, but I personally display the last message content for the user to edit if need be or even remove then add their content and send.
Last message id would not need to be added to the database at all unless you are going to try and run a query to say count() the amount of replies a particular message has had. (creating a relationship betweent the messages) Almost like counting the comment posts on a particular comment thread.
If you are wanting to incorporate the tickbox scenario then you have a couple of choices to choose from:
Allow the box to be ticked which would display the last message content recieved by using javascript again giving user option to change it
Allow the box to be ticked which would just add the last message content recieved to the end of the message etc not allowing the user to change it
or just simply grab the details of the last message content and display in textarea for user to do as they deem fit without the tickbox scenario.
I must say it is becoming the standard that the previous message is displayed in the reply for the user to have the choice to either send as is along with their reply or change it if required because they are sending the message to another person etc.
You need to decide which option and scenario you are wanting which best suits your development needs.
Code: Select all
if(isset($_POST['formSubmit']) {
if ($_POST['formOriginal'] == 'Yes') { // GRAB PREVIOUS MESSAGE CONTENT TO DISPLAY USING $_POST['last_message_id'] VIA SQL QUERY
}
else { // DO NOT DISPLAY PREVIOUS MESSAGE FOR USER
}
}
The above little code is how you would normally complete that task by checking to see if the form had been submitted first of all then also checking to see if the value existed along with the submission. But you would also need to have the message_id submitted along with it as a hidden field so your reply script nows which previous message contents to display to the user.
So:
Code: Select all
<form action = "reply.php" method = "POST">
<input type = "hidden" name = "last_message_id" value = "<php echo $last_message_id; ?>" />
<input type = "checkbox" name = "formOriginal" value = "y" />
<input type = "submit" name = "formSubmit" value = "Reply" />
</form>
So when you are displaying the message to begin with to the user y (for example) you would have to have grabbed the message_id of user x message and save to string $last_message_id etc to forward to your new script for the reply. Your new script would then pull the email to details, and using the $_POST['last_message_id'] run q query on the database to extract the message and display in a textarea box for the user to do as they please with it.
Just confirm a few things first before you go ahead and change the scripts etc
Best wishes