Problems, need help? Have a tip or advice? Post it here.
10 posts Page 1 of 1
Hi,

since I'm not that well versed in php I could use a little help:

What I would like to do is to redirect the user after he submitted a form. What I have now is a form like in the tutorials (http://www.couchcms.com/docs/concepts/forms.html) which just shows a little success message if it was properly submitted. If the form is a bit longer (or the screen height not that big) one doesn't really see the message and believes that nothing happened. That's why I sometimes get several mails with the same content.

If I could either focus the top of the page with the form (I have an anchor "#top") or redirect to a different page after successfully submitting the form it would be more obvious.

I'm not yet sure which of the two options I prefer but I guess there is no real difference ;). Although for the second options I would need a link which brings the user to the exact same page where he submitted the form. Again, I'm not really good in php, but I guess there must be an option to "go back". Or does even couch supports something like this?

Thanks in advance!
I'm not that well versed in php either, fortunately though in this case we don't need to be. :)

I don't think a redirect is necessary. I believe by default on forms, couch sets a url hash (example: http://www.website.com/contact/#contact_form) that matches the form tag's id. This is the case when anchor='1' is set for the 'cms:form' tag. If you would like to be taken to a different element id on submission, you could use the following parameters for the 'cms:form' tag:
Code: Select all
anchor='0' action='#top'

I think the duplicate submissions issue is evidence of a usability problem. The user apparently is not certain their message has been sent after the first submission. I think you should provide more visual confirmation to the user that their message has been submitted correctly the first time. You could try a few different things, depending on your preference:

1. Place the success message at the top of the form.
2. Remove the submit button on successful submission.
3. Remove all form inputs and submit button on successful submission.

I have used the third method in the past, so I will demonstrate what to do in-case you are not sure how to accomplish this:
Code: Select all
<cms:form name='contact_form' anchor='0' action='#top' method='post'>
     <cms:if k_success >
          **SEND_MAIL TAG**
          Success Message
     <cms:else/>
          <cms:if k_error >
          Error Message
          </cms:if>
          **INPUTS/SUBMIT BUTTON**
     </cms:if>
</cms:form>
Thank you very much!
even my blog comment submission form hasnt been working!!
i donno if i skipped the part in the tutorial (or it's just not there) where they say
Code: Select all
action='#top'

my contact form kept sending me back to the homepage without even submitting the mail!! all i did was add
Code: Select all
action='contact/'
since my contact form is in an entirely seperate folder... contact/index.php

:)

only problem i hav now is gettin the success message to display the name that was entered in the form, i have tried
Code: Select all
<cms:show k_success_name />
and
Code: Select all
<cms:show k_success_frm_name />
still not gettin anything..
---
You live many times, but only ever remember your lives.length - 1
---
Image
@cholasimmons,
Can you paste in the exact form code that you have been using please?
i think it was copied out of a tutorial, never worked even then, so i tweaked it abit to match my site, still never worked, and the Contact Form trick i use of adding
Code: Select all
action='blog/'
isnt working here coz blog/ will submit the form contents to the blog list view and i want it to submit it to itself (blog page view)! cant recall the cms code to use to get current url.


Code: Select all
<cms:if k_is_commentable >
   <div class="comment-form" style="width:100%" >
      <h3>Add a Comment</h3>

      <cms:form method="post" class="k_form" action="#commentform">

         <cms:if k_success >
         
            <cms:process_comment />

            <cms:if k_process_comment_success>
               <cms:send_mail from=k_email_from to=k_email_to subject='Comment posted'>
                  The following comment has been posted at your site:
                  <cms:show k_success />
               </cms:send_mail>
                  
               <div class="k_successmessage">
                  <p>
                     Thank you for the feed back! <br>
                     Your comment awaits moderation and will be published as soon as reviewed by the Admin.
                  </p>
               </div>
            <cms:else />
               <div class="k_errormessage">
                  <p>
                     Could not post comment! <br>
                     The following error occured while processing your comment:<br>
                     <cms:show k_process_comment_error />
                  </p>
               </div>
            
            </cms:if>
            
         <cms:else />
         
            <cms:if k_error >
               <div class="k_errormessage">
                  <h2>Fields incomplete!</h2>
                  <ul>
                     <cms:each k_error >
                        <li><cms:show item /></li>
                     </cms:each>
                  </ul>
               </div>
            </cms:if>
            
            <cms:if k_logged_out >
               <p class="comment-input">
                  <cms:input type="text" name="k_author" size="22" tabindex="1" required="1"/>
                  <label for="author"><small>Your Name *</small></label>
               </p>

               <p class="comment-input">
                  <cms:input type="text" name="k_email" size="22" tabindex="2" validator="email" required="1"/>
                  <label for="email"><small>Email *(not published)</small></label>
               </p>

               <p class="comment-input">
                  <input type="text" name="k_link" value="http://" size="22" tabindex="3" />
                  <label for="link"><small>Website</small></label>
               </p>
            <cms:else />
               <p>
                  Logged in as <b><cms:show k_user_title /></b>.
                  <a href="<cms:show k_logout_link />" onclick="if( confirm('Are you sure you want to logout?') ) { return true; } return false;">Logout &raquo;</a>
               </p>
            </cms:if>
            
            <p class="comment-input">
               <cms:input type="textarea" name="k_comment" style="width:93%" rows="6" cols="9" tabindex="4"
                  validator_msg="required=Please enter something as comment"
                  required="1" />
               
               <br>
               <small>
               You can use the following HTML tags: <br/><b>
               <cms:html_encode>
                  <a><br><strong><b><em><i><blockquote><pre><code><ul><ol><li><del>
               </cms:html_encode></b>
               </small>
            </p>

            <cms:if k_logged_out >
            <small>Please enter the letters into the textbox</small><br/>
            <label for="captcha">
             <p class="comment-input">
             <cms:input type="captcha" name="captcha" format='i-r-t' />
            </label>
             </p>
            </cms:if>
<center>
            <cms:input type="submit" value="Post Comment" name="submit"/>
</center>
         </cms:if>
      </cms:form>
      
   </div>
</cms:if>
---
You live many times, but only ever remember your lives.length - 1
---
Image
If you leave the 'action' attribute blank it will just submit to the current page. Submitted values of all fields in the form are available as variables of the same names prefixed by 'frm_'. If for example the form had two fields 'name' and 'email', Couch would make available the values submitted through them as variables named 'frm_name' and 'frm_email'.

I copy/pasted your code and it worked fine. What exactly happens when you submit this form? Did you make sure to set your template as commentable?
<cms:template commentable='1'/>
Initially there was no "action" tag, it still redirected to my homepage, even after i added "action=''" and "action='#top'" it still did the same and no comment was submitted, i had this problem with the email form on the contact us page, i had to add "action='contact/index.php'" because my site is divided into subdomains, hence the blog page is simmonsstudio.tk/blog/ but the form redirects me back to just simmonsstudio.tk
template is commentable (='1')
any other ideas??

PS: I just remembered that in the <base /> tag at the top of my html code, i set target to _parent, i guess thats why blog/index.php redirected me to it's parent page. But i changed the <base /> tag to _self, the comment form is still redirecting to the parent page,
does anybody know the cms code that outputs the current url you are on? my plan is to add that code to action in the comment form ;)
---
You live many times, but only ever remember your lives.length - 1
---
Image
I guarantee if you just remove the <base/> tag your forms will work fine...

In regard to your question:
For your blog comment form, the URL would be: <cms:show k_page_link/>
For your contact form, the URL would be: <cms:link 'contact/index.php'/>
cheesypoof wrote: I guarantee if you just remove the <base/> tag your forms will work fine...


My Man! :lol: you aced it!! now i gotta figure how to display the comments and my site will be up n running! :)
Thank You Cheesy
---
You live many times, but only ever remember your lives.length - 1
---
Image
10 posts Page 1 of 1