Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
I am using the couch forms tags for a site and the error handling works great, but whenever I submit for success, the success message doesn't load and it adds this to the URL: http://XXXX.com/#kformname0

When I set the form to debug, the txt file says that it has been sent successfully. Unfortunately the success message doesn't appear on the page and the email doesn't actually go out. Any idea where I am going wrong?

Code: Select all
<cms:if k_success>
                           <div class="gap-10"></div>
                           <div class="alert alert-success" role="alert">Success! Your message has been sent and we will be in touch shortly.</div>
                           <cms:send_mail from='hello@xxx.com' to='jon@xxx.com' subject='New  Contact Form'>
                              Below are the contact details from the user:
                              <cms:show k_success />
                           </cms:send_mail>
                        </cms:if>
                        <cms:form action='' method='post' id='contact_form' accept-charset="utf-8">
                           <label>Name</label>
                           <cms:input type='text' name='name' id='name' required='1'/>
                           <cms:if k_error_name>
                              <div class="gap-10"></div>
                              <div class="alert alert-danger" role="alert">Please enter your name.</div>
                           </cms:if>
                           <label>Email address</label>
                           <cms:input type='text' name='email' id='email' required='1' validator='email' />
                           <cms:if k_error_email>
                              <div class="gap-10"></div>
                              <div class="alert alert-danger" role="alert">Please enter a valid email.</div>
                           </cms:if>
                           <label>Phone number</label>
                           <cms:input type='text' name='phone' id='phone' />
                           <label>Message</label>
                           <cms:input class="mes" type='textarea' name='message' id='message' required='1'></cms:input>
                           <cms:if k_error_message>
                              <div class="gap-10"></div>
                              <div class="alert alert-danger" role="alert">Please enter your message.</div>
                           </cms:if>
                           <input class="submit" type="submit" value="Send Message">
                        </cms:form>
Hi Ton,

You are using the k_success block outside the cms:form block, which is wrong.
Please move the entire <cms:if k_success> .. </cms:if> to inside the <cms:form> block e.g. as follows -
Code: Select all
<cms:form action='' method='post' id='contact_form' accept-charset="utf-8">

    <cms:if k_success>
        <div class="gap-10"></div>
        <div class="alert alert-success" role="alert">Success! Your message has been sent and we will be in touch shortly.</div>
        <cms:send_mail from='hello@xxx.com' to='jon@xxx.com' subject='New  Contact Form'>
            Below are the contact details from the user:
            <cms:show k_success />
        </cms:send_mail>
    </cms:if>
   
    <label>Name</label>
    <cms:input type='text' name='name' id='name' required='1'/>
    ...
    ...
    <input class="submit" type="submit" value="Send Message">
</cms:form>

Hope this helps.
Thanks KK. This definitely helps. I now get the success message but still getting that URL on submit (I am in a local environment) http://localhost:8888/#kformname0 and still not receiving the emails, but could that be because I am in my local environment?
Yes that could be the reason. Usually it is not possible to send emails through local setups.
You'll have to check it once the site is online.
Works great now! Thank you KK. Should I still be seeing the #kformname0 in the URL on submit?
Please try using anchor='0' with the cms:form tag to get rid of that.
Hope it helps.
6 posts Page 1 of 1