5 Replies Latest reply on Oct 16, 2007 12:58 PM by Newsgroup_User

    Posted Comments after submitted

    WOLFcfm Level 1
      Hi,
      The comments users post don't show right after its been submitted, they are only shown after the page is refreshed.
      How can I fix this so the comments show right away after the form is submitted into the database?
      Thanks in advance for any type of help.
        • 1. Re: Posted Comments after submitted
          Dan Bracuk Level 5
          Your post does not provide enough information. What are you doing now?
          • 2. Posted Comments after submitted
            WOLFcfm Level 1
            ok, for example:
            you have a web page with a form where users can type a comment and under the form you have previous users comments. im trying to set it up so when an user posts a comment, the comment will be displayed immediately after the form is submitted.

            i dont know if you need to take a look at my insert code but just in case you do here it is.

            <cfquery name="insertpost" datasource="myData">
            insert into posts (stamp, message, username) values (#now()#, '#form.comment#', '#form.username#')
            </cfquery>



            thanks...
            • 3. Re: Posted Comments after submitted
              Dan Bracuk Level 5
              What is more relevent is,

              Is your form submitting to itself or to the same page?
              What code comes after the insert query?
              Is there a select query that gets the users comments? If so, does it run before or after the insert?
              • 4. Re: Posted Comments after submitted
                WOLFcfm Level 1
                the form is submitting to the same page, and after the insert query i have the query to display the comments. heres the set up:



                THIS IS DATABASE FOR THE COMMENTS

                <cfquery name="displaycommentinfo" datasource="dgr">
                select message
                from posts
                </cfquery>


                THEN I HAVE THE FORM AND UNDER THE FORM IS THIS INSERT CODE


                <cfif isdefined("form.comment")>

                <cfif good is 1>
                <cfquery name="insertpostinfo" datasource="dgr">
                insert into posts ( message) values (#form.comment#')
                </cfquery>
                </cfif>

                </cfif>

                UNDER THAT IS IS MY DISPLAY CODE


                <cfoutput query="displaycommentinfo">
                <span class="content">#message#</span>
                </cfoutput>


                AND THATS IT.


                Thanks again...
                • 5. Re: Posted Comments after submitted
                  Level 7
                  There is your answer.

                  First you query the database.

                  Second you display a form.

                  THEN you insert the new comment from the previous form submit.

                  Finally you display the results of your query done in the first step,
                  before any new data was added.