Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hello, i buy website template with scripts for email sending, but it doesn't work together with couchCMS.

Code: Select all
<div id="message-info"></div>
<cms:form method="post" id="contactform" anchor='1' action="">
    <div class="col-sm-12">
        <cms:input type="text" name="name" id="name" placeholder="Vaše jméno a příjmení *" />
    </div>
    <div class="col-sm-6">
        <cms:input type="email" name="email" id="email" placeholder="Váš e-mailová adresa *" />
    </div>
    <div class="col-sm-6">
        <cms:input type="text" name="phone" id="phone" placeholder="Váše telefonní číslo"/>
    </div>
    <div class="col-sm-12">
        <cms:input type="textarea" name="message" rows="9" id="message" placeholder="Vaše zpráva *" />
    </div>
    <div class="col-sm-12 checkbox">
        <cms:input name="gdpr" opt_values="Souhlasím se zpracováním osobních údajů" type='checkbox' />
    </div>

    <cms:if k_success >
        <cms:send_mail from=k_email_from to=k_email_to subject='Vyplněný formulář z webu'>
            <!doctype html>
            <html>
                <body>
                    <p style="font-size:large;">
                        Kontaktní formulář:<br/><br/>
                        <strong>Jméno a příjmení:</strong> <cms:show frm_name/><br/>
                        <strong>E-mail:</strong> <cms:show frm_email/><br/>
                        <strong>Telefonní číslo:</strong> <cms:show frm_phone/><br/>
                        <strong>Zpráva:</strong><br/>
                        <cms:nl2br><cms:show frm_message/></cms:nl2br><br/>
                        <strong>Souhlas se zpracováním osobních údajů.</strong> Ano<br/>
                    </p>
                </body>
            </html>
        </cms:send_mail>
    </cms:if>

    <div class="col-md-12">
        <cms:input type="submit" name="submit" class="submit btn btn-lg btn-primary" id="submit" value="Odeslat zprávu"/>
    </div>
</cms:form>


Code: Select all
function contactForm() {
        $('#contactform').submit(function () {
            var action = 'contact.php';
            $("#message-info").slideUp(250, function () {
                $('#message-info').hide();
                $('#submit')
                    .after('<div class="loader"><div></div></div>')
                    .attr('disabled', 'disabled');
                $.post(action, {
                    name: $('#name').val(),
                    email: $('#email').val(),
                    phone: $('#phone').val(),
                    message: $('#message').val()
                },
                    function (data) {
                        document.getElementById('message-info').innerHTML = data;
                        $('#message-info').slideDown(250);
                        $('#contactform .loader div').fadeOut('slow', function() {
                            $(this).remove();
                        });
                        $('#submit').removeAttr('disabled');
                        if (data.match('success') !== null) {
                            $('#contactform').slideUp(850, 'easeInOutExpo');
                        }
                    });
            });
            return false;
        });
    }


Please, help.
Hi,

From what I can see, you are calling a regular Couch template 'contact.php' via AJAX using your custom JS.
So what exactly is not working?
Is the email not being sent? Or the custom script you are using is not getting back data from contact.php?

If the email is not being sent, first test contact.php without AJAX (i.e. by directly visiting it and manually submitting the form).
You are trying to send HTML mail so perhaps you'd be better off using PHPMailer addon (viewtopic.php?f=5&t=10750).

Once you can get the mail to go through, turn your attention to the AJAX script.
I think you'll need to use <cms:abort> within the k_success block after the mail is sent e.g. as follows to send only the message back to your AJAX code (as of now, I think the entire page is being sent back).
Code: Select all
<cms:abort>
Thanks for contacting us. We'll get back ASAP.
</cms:abort>

Hope the reply helps.

I mean, website don't send e-mail when i using this script. If i delete script, everything is working good but form cannot hide and in url is ugly "domain.cz/#formdata()" or something like that. I just want send email like in html code below with hiding form after email send, with message after send and with pure url like domain.cz if i am at homepage.
See, this is purely a front-end issue - Couch's domain is the server and the form is working fine at that level.
My apologies but I won't be able to help you troubleshoot front-end JS (it is not my strong suite, in any case).
Perhaps someone better versed in JS on the forum would like to take a look into this issue.
4 posts Page 1 of 1