We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Problem

Can't get mailchimp subscribe working in contact form

Hi Drew, I've added a join mailing list check box to a contact us form. The for is submitting and I'm receive an email with all the details however the mailchimp subscription isn't working.

Below is the form I'm using.


<perch:form id="contact" method="post" app="perch_mailchimp perch_forms" class="contact-form" double-optin="true"> <h1><perch:content id="heading" type="smarttext" label="Heading" textile="true" editor="markitup" /></h1> <perch:content id="intro" type="textarea" label="Intro" textile="true" editor="markitup" size="m" /> <p>Fields marked with an<span class="mandatory">*</span>are required to be completed.</p> <div> <perch:label for="confirm" class="mailing group">Join our mailing list</perch:label> <perch:input type="checkbox" value="1" id="confirm" mailer="confirm_subscribe" tabindex="10"/> </div> <div> <perch:label for="message" >Message</perch:label> <perch:input type="textarea" id="message" label="Message" tabindex="1"/> </div> <p class="instruct">Please provide us with your contact details… <br> …don’t forget to include your address if you’re requesting samples.</p> <div> <perch:label for="name" class="group">Name<span class="mandatory">*</span></perch:label> <perch:input type="text" id="name" required="true" label="Name" tabindex="2" class="short"/> <perch:error for="name" type="required">Please add your name</perch:error> </div> <div> <perch:label for="Telephone">Contact number</perch:label> <perch:input type="tel" id="Telephone" label="Telephone" tabindex="3" placeholder="Landline or mobile" class="short"/> </div> <div> <perch:label for="email">Email<span class="mandatory">*</span></perch:label> <perch:input type="email" id="email" required="true" label="Email" placeholder="you@yourdomain.com" tabindex="4" class="short"/> <perch:error for="email" type="required">Please add your email address</perch:error> <perch:error for="email" type="format">Please check your email address</perch:error> </div> <div> <perch:label for="house" class="group">Building Name/No. </perch:label> <perch:input type="text" id="house" label="House No./Name" tabindex="5" class="short"/> <perch:label for="street">Street</perch:label> <perch:input type="text" id="street" label="Street" tabindex="6" class="short"/> <perch:label for="town">Town/City</perch:label> <perch:input type="text" id="town" label="Town/City" tabindex="7" class="short"/> <perch:label for="county">County/State</perch:label> <perch:input type="text" id="county" label="Town/City" tabindex="8" class="short"/> <perch:label for="postcode">Postcode/Zip</perch:label> <perch:input type="text" id="postcode" label="postcode" tabindex="9" class="short"/> <perch:label for="country">Country</perch:label> <perch:input type="text" id="country" label="country" tabindex="10" class="short"/> </div> <div class="hide"> <perch:label for="human">Please leave this field blank:</perch:label> <perch:input type="text" id="human" antispam="honeypot" /> </div> <div class="loginlast group"> <perch:label for="submit"> </perch:label><perch:input type="submit" id="submit" value="Submit" tabindex="11"/> <perch:input type="hidden" id="list" value="XXXXXXXXXXX" mailer="list" /> </div> <perch:success> <div class="content-area"> <h1><perch:content id="success" type="text" label="Thank you title" textile="true" editor="markitup" /></h1> <perch:content id="successmessage" type="textarea" label="Thank you message" textile="true" editor="markitup" /> </div> </perch:success> </perch:form>

Any pointers as to what I'm doing wrong. On the standalone mailchimp subscribe form the value of the submit button is Join, does this make a difference?

Nick Loat

Nick Loat 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What output do you get from debug?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I can't see the form being posted there at all. Are you sure it's posting?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you sure that's not from the control panel?

Doh. Finally understood what you were after…

Debug Message
[1] SELECT * FROM perch2_pages WHERE pagePath='/contact.php' LIMIT 1
[57] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1] SELECT * FROM perch2_mailchimp_lists WHERE listMailChimpID='03fc1c9092' LIMIT 1
Subscribing to: Rapture and Wright 2016

Array
(
    [headers] => Array
        (
            [url] => https://us4.api.mailchimp.com/3.0/lists/03fc1c9092/members
            [content_type] => application/problem+json; charset=utf-8
            [http_code] => 400
            [header_size] => 416
            [request_size] => 373
            [filetime] => -1
            [ssl_verify_result] => 0
            [redirect_count] => 0
            [total_time] => 0.421195
            [namelookup_time] => 0.000582
            [connect_time] => 0.006374
            [pretransfer_time] => 0.07089
            [size_upload] => 41
            [size_download] => 288
            [speed_download] => 683
            [speed_upload] => 97
            [download_content_length] => 288
            [upload_content_length] => 0
            [starttransfer_time] => 0.421122
            [redirect_time] => 0
            [redirect_url] => 
            [primary_ip] => 23.214.182.253
            [certinfo] => Array
                (
                )

            [request_header] => POST /3.0/lists/03fc1c9092/members HTTP/1.0
User-Agent: DrewM/MailChimp-API/3.0 (github.com/drewm/mailchimp-api)
Host: us4.api.mailchimp.com
Accept-Encoding: deflate, gzip
Accept: application/vnd.api+json
Content-Type: application/vnd.api+json
Authorization: apikey d14886cc8f69d57462b8d13ccb0572d6-us4
Content-Length: 41


        )

    [body] => {"type":"http://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/","title":"Invalid Resource","status":400,"detail":"The resource submitted could not be validated. For field-specific details, see the 'errors' array.","instance":"","errors":[{"field":"","message":"Required fields were not provided: email_address"},{"field":"email_address","message":"Schema describes string, NULL found instead"}]}
)

[1] SELECT * FROM perch2_forms WHERE formKey='contact' LIMIT 1
Using email template: /home/sites/raptureandwright.co.uk/public_html/admin/templates/forms/emails/enquiry.html (html)
Setting confirm as 1
Setting message as Hello
Setting name as Nick
Setting Telephone as 07970024271
Setting email as harry@loatdavies.com
Setting house as
Setting street as
Setting town as
Setting county as
Setting postcode as
Setting country as
Setting list as 03fc1c9092
Building message with Perch template
[1] Using template: /templates/forms/emails/enquiry.html
Sent email: "Nick has sent a message via the website contact form" to info@raptureandwright.co.uk, rebecca@raptureandwright.co.uk, nick@loatdavies.com
INSERT INTO perch2_forms_responses(responseJSON,formID,responseIP,responseSpamData) VALUES('{\"fields\":{\"confirm\":{\"attributes\":{\"type\":\"checkbox\",\"value\":\"1\",\"id\":\"confirm\",\"mailer\":\"confirm_subscribe\",\"tabindex\":\"10\"},\"value\":\"1\"},\"message\":{\"attributes\":{\"type\":\"textarea\",\"id\":\"message\",\"label\":\"Message\",\"tabindex\":\"1\"},\"value\":\"Hello\"},\"name\":{\"attributes\":{\"type\":\"text\",\"id\":\"name\",\"required\":\"true\",\"label\":\"Name\",\"tabindex\":\"2\",\"class\":\"short\"},\"value\":\"Nick\"},\"Telephone\":{\"attributes\":{\"type\":\"tel\",\"id\":\"Telephone\",\"label\":\"Telephone\",\"tabindex\":\"3\",\"placeholder\":\"Landline or mobile\",\"class\":\"short\"},\"value\":\"07970024271\"},\"email\":{\"attributes\":{\"type\":\"email\",\"id\":\"email\",\"required\":\"true\",\"label\":\"Email\",\"placeholder\":\"you@yourdomain.com\",\"tabindex\":\"4\",\"class\":\"short\"},\"value\":\"harry@loatdavies.com\"},\"house\":{\"attributes\":{\"type\":\"text\",\"id\":\"house\",\"label\":\"House No.\\/Name\",\"tabindex\":\"5\",\"class\":\"short\"},\"value\":\"\"},\"street\":{\"attributes\":{\"type\":\"text\",\"id\":\"street\",\"label\":\"Street\",\"tabindex\":\"6\",\"class\":\"short\"},\"value\":\"\"},\"town\":{\"attributes\":{\"type\":\"text\",\"id\":\"town\",\"label\":\"Town\\/City\",\"tabindex\":\"7\",\"class\":\"short\"},\"value\":\"\"},\"county\":{\"attributes\":{\"type\":\"text\",\"id\":\"county\",\"label\":\"Town\\/City\",\"tabindex\":\"8\",\"class\":\"short\"},\"value\":\"\"},\"postcode\":{\"attributes\":{\"type\":\"text\",\"id\":\"postcode\",\"label\":\"postcode\",\"tabindex\":\"9\",\"class\":\"short\"},\"value\":\"\"},\"country\":{\"attributes\":{\"type\":\"text\",\"id\":\"country\",\"label\":\"country\",\"tabindex\":\"10\",\"class\":\"short\"},\"value\":\"\"},\"list\":{\"attributes\":{\"type\":\"hidden\",\"id\":\"list\",\"value\":\"03fc1c9092\",\"mailer\":\"list\"},\"value\":\"03fc1c9092\"}},\"files\":[],\"page\":{\"id\":\"20\",\"title\":\"Contact\",\"path\":\"\\/contact.php\",\"navtext\":\"Contact\"}}','1','79.77.170.223','{\"fields\":{\"honeypot\":\"\"},\"environment\":{\"PATH\":\"\\/usr\\/local\\/bin:\\/usr\\/bin:\\/bin\",\"UNIQUE_ID\":\"V@qgb38AAAEAAR6bRFAAAAAV\",\"SCRIPT_URL\":\"\\/contact.php\",\"SCRIPT_URI\":\"http:\\/\\/raptureandwright.co.uk\\/contact.php\",\"HTTP_HOST\":\"raptureandwright.co.uk\",\"HTTP_USER_AGENT\":\"Mozilla\\/5.0 (Macintosh; Intel Mac OS X 10.12; rv:51.0) Gecko\\/20100101 Firefox\\/51.0\",\"HTTP_ACCEPT\":\"text\\/html,application\\/xhtml+xml,application\\/xml;q=0.9,*\\/*;q=0.8\",\"HTTP_ACCEPT_LANGUAGE\":\"en-GB,en;q=0.5\",\"HTTP_ACCEPT_ENCODING\":\"gzip, deflate\",\"HTTP_REFERER\":\"http:\\/\\/raptureandwright.co.uk\\/contact.php\",\"HTTP_COOKIE\":\"_ga=GA1.3.1965182018.1474993656; __atuvc=17%7C39; __atuvs=57ea9df60b30c72c010; PHPSESSID=hts19ig7629p4hlrf856vmhoj6; cmsa=1\",\"HTTP_UPGRADE_INSECURE_REQUESTS\":\"1\",\"CONTENT_TYPE\":\"application\\/x-www-form-urlencoded\",\"CONTENT_LENGTH\":\"293\",\"HTTP_CONNECTION\":\"close\",\"SERVER_SIGNATURE\":\"\",\"SERVER_SOFTWARE\":\"Apache\\/2.4.23 (Unix)\",\"SERVER_NAME\":\"raptureandwright.co.uk\",\"SERVER_ADDR\":\"10.0.1.178\",\"SERVER_PORT\":\"80\",\"REMOTE_ADDR\":\"79.77.170.223\",\"DOCUMENT_ROOT\":\"\\/home\\/sites\\/raptureandwright.co.uk\\/public_html\",\"REQUEST_SCHEME\":\"http\",\"CONTEXT_PREFIX\":\"\",\"CONTEXT_DOCUMENT_ROOT\":\"\\/home\\/sites\\/raptureandwright.co.uk\\/public_html\",\"SERVER_ADMIN\":\"root@localhost\",\"SCRIPT_FILENAME\":\"\\/home\\/sites\\/raptureandwright.co.uk\\/public_html\\/contact.php\",\"REMOTE_PORT\":\"34839\",\"GATEWAY_INTERFACE\":\"CGI\\/1.1\",\"SERVER_PROTOCOL\":\"HTTP\\/1.1\",\"REQUEST_METHOD\":\"POST\",\"QUERY_STRING\":\"\",\"REQUEST_URI\":\"\\/contact.php\",\"SCRIPT_NAME\":\"\\/contact.php\",\"PHP_SELF\":\"\\/contact.php\",\"REQUEST_TIME_FLOAT\":1474994287.5932,\"REQUEST_TIME\":1474994287}}')
[1] SELECT * FROM perch2_forms_responses WHERE responseID='293' LIMIT 1
No ids to log.
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using sub-template: /templates/pages/attributes/pagination.html
[40] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=2 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/contact.php' LIMIT 1
[1] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-009', '000') ORDER BY pageTreePosition DESC
[7] Using template: /templates/navigation/item.html
[5] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/contact.php' OR regionPage='*' ORDER BY regionPage DESC

Array
(
    [type] => 8
    [message] => Undefined variable: email
    [file] => /home/sites/raptureandwright.co.uk/public_html/admin/addons/apps/perch_mailchimp/lib/PerchMailChimp_Subscribers.class.php
    [line] => 68
)
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think you're missing the mailer="email" attribute on your email field.