Need help with Reviewing/Editing a Comments Form

I just added the ability for Users to add Comments to articles on my website.

However, it occurred to me today on my way to supper that I haven’t given Users the ability to “preview” or “edit” their Comments before they are submitted for good?! :blush:

I am not really sure how to go from my Comments Form to re-displaying the User’s Comments to allow previewing and editing?! :-/

For instance, where do I store things going from the Form to the Preview?

Do I store the Comments in $_SESSION?

Do I store the Comments in my Database?

Something else?

I could use some help and direction on how to tackle this!!

Hopefully it won’t be too hard to add this extra functionality on to my Comments Form?!


Hi Debbie,

Others will have differing views on this and will say to store it in sessions, or do it this way or that way…

Personally, I would serialze the form data and write it to the database. Then I would pull it from the database using AJAX that calls a php script that returns a preview of this data. I would store in the Session the Id of the serialized data in your table so that you know what serialized record to get, and then I would use AJAX again to post this data to a php script that writes it too the database.

Using this method the user will never leave the page and can preview and commit (or cancel) too.


Thanks for the suggestion, but I’m not ready for AJAX yet?! :eek:

So, with that option out, what would be a more “plain-vanilla” approach?

If the User is on the “Add a Comment” form on my Article page, then it would seem easiest to do this…

  • Display the Comments Form
  • Have a “Submit” button
  • Have a “Preview” button
  • If the User clicks “Submit”, then write it to the Database
  • If the User clicks “Preview”, then store the data in $_SESSION
  • Display a “Preview” page with the User’s Comments shown how they will look when they are submitted, and display the “Add a Comment” form below this with the Form pre-populated with data from the $_SESSION.


[SIZE=2][FONT=georgia]Hi Debbie,

Your way will work. You could skip the overhead of the database and sessions stuff by doing something like:[LEFT][COLOR=#800080][B]

  /Do preview php code here
  /Do submit php code here
<form method='POST' action='my_form.php'>
 <input type='text' name='info'>
 <input name='submit' type='submit' value='submit'>
 <input name='preview' type='submit' value='preview'>


Good suggestion. That is what I am playing with now.