Forum for discussing general topics related to Couch.
4 posts Page 1 of 1
Hi

I have a client who I designing a website for and they have asked if it's possible to have the contact form submissions stored in the couchcms database and also have a time stamp of accepting the terms check box on the contact form

Below is the current code for the form

Code: Select all
<form name="contactForm" id="contact_form" method="post" action="#">
                            <div class="row g-4">
                                <div class="col-lg-12">
                                    <div class="field-set">
                                        <input type="text" name="Name" id="name" class="form-control" placeholder="Your Name" required>
                                    </div>
                                    <div class="field-set">
                                        <input type="text" name="Email" id="email" class="form-control" placeholder="Your Email" required>
                                    </div>
                                    <div class="field-set">
                                        <input type="text" name="phone" id="phone" class="form-control" placeholder="Your Phone" required>
                                    </div>
                                    <div class="field-set">
                                        <select name="service" class="form-control">
                                            <option>Service Inquiry Type</option>
                                            <option value="Repairs">Repairs</option>
                                            <option value="IT Support">IT Support</option>
                                            <option value="Retainer Packages">Retainer Packages</option>
                                            <option value="Other">Other</option>
                                        </select>
                                    </div>
                                    <div class="field-set">
                                        <textarea name="message" id="message" class="form-control h-100px" placeholder="Your Message" required></textarea>
                                    </div>

                                    <div class="field-set">
                                        <input type="checkbox" id="agree" name="agree">
                                        <label for="agree" class="text-light">I have read and agree to the <a href="privacy-policy.php" target="_blank">Privacy Policy</a></label>
                                    </div>
                                </div>
                            </div>
                            <div id='submit' class="mt-3">
                                <input type='submit' id='send_message' value='Send Message' class="btn-main">
                            </div>
                        </form>


I have not done a contact form before using couchcms as normally just do the form and the code to send it to the admin and the user who filled out the form is redirected to a confirmation page after form submission
Hi,

You can make the form 'databound' - https://docs.couchcms.com/concepts/databound-forms.html

Hope this helps.
KK wrote: Hi,

You can make the form 'databound' - https://docs.couchcms.com/concepts/databound-forms.html

Hope this helps.


Hi KK

Thank you for your reply. I have tried to have a go myself using the demo code as a example to put on my contact form page but having the following issues

1) When I refresh the contact page, I keep getting a email come through saying the following

"The following is an contact form enquiry sent by a visitor to your contact page:

name:
email:
phone:
Service Type:
message:
Agree to privacy policy:"

2) When I submit the form, I get the email come through as the admin but the data the visitor filled in is blank on the email I get as admin

3) The visitor who filled out the form does not get a confirmation email, I think it's because I have two send_mail tags which looks like is the issue and can only have one send_mail tag

4) On the couchcms side, the form is not being added to the couchcms side like the example shows for the databound forms

I have attached the current contact.php as a zip file

Attachments

Hi

I have had another look at it and have added the html snippet called my_list.html info the snippets folder and added the line to the kfunctions.php file and have managed to get the form enquiries displayed on the admin side now but it's looking bit messy and not a nice table layout. I have attached a screenshot of that issue

The other issues I have are below

1) Each time I visit the contact.php on the front end, it's submitting the form and I keep getting emails come through with no data. I'm assuming that is because the fields are not filled in when I visit the page. How do I get the form to not submit when visit the page but only submit it when I click the submit button

2) When I do fill the form fields out and click submit, the data I entered in the form field on the front end on contact.php is not showing on the email I receive as admin. It just shows name:

I have attached the latest contact.php file as a zip file

Attachments

4 posts Page 1 of 1