Forum

Thread tagged as: Problem, Error, Forms

Perch Form Not working

We have a contact form on our site, which was working well - it's now no longer working. Last recorded successful submission, 1st Dec 2015. Not sure whether a server update happened. I'm not aware of any changes to our site.

We have updated Perch and the Perch forms app to the latest version, but we're still seeing the issue. When we submit the form, the page comes back up without error or success message - just the blank form again.

Here's the diagnostic report:

Perch: 2.8.24, PHP: 5.5.31, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 15d5c781cfcad91193dceae1d2cdd127674ddb3e $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.24), assets (2.8.24), categories (2.8.24), perch_events (1.9.2), perch_forms (1.8.3)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_events', 'perch_forms', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home4/SITE/public_html/perch
PERCH_CORE: /home4/SITE/public_html/perch/core
PERCH_RESFILEPATH: /home4/SITE/public_html/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 128M, Max POST 128M, Memory: 128M, Total max file upload: 128M
F1: dc1fef2ad0fcd9f943c02ebb43d85dbc
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /home4/SITE/public_html
HTTP_HOST: www.SITE.co.uk

Here's the page template (in templates > content )

<perch:form id="booking" method="post" app="perch_forms">

    <perch:content id="intro" type="textarea" label="Intro" textile="true" editor="markitup" size="m" />

    <perch:error for="all" type="general"><p><span class="error">
        Sorry, something went wrong and the form was not sent. Please see the messages below.
    </span></p></perch:error>

    <div>
        <perch:label for="name">Name</perch:label>
        <perch:input type="text" id="name" required="true" label="Name" />
        <perch:error for="name" type="required"><span class="error">Please add your name</span></perch:error>
    </div>

    <div>
        <perch:label for="telephone">Telephone</perch:label>
        <perch:input type="text" id="telephone" required="true" label="Telephone" />
        <perch:error for="telephone" type="required"><span class="error">Please add a phone number</span></perch:error>
    </div>

    <div>
        <perch:label for="email">Email</perch:label>
        <perch:input type="email" id="email" required="true" label="Email" placeholder="you@company.com" />
        <perch:error for="email" type="required"><span class="error">Please add your email address</span></perch:error>
        <perch:error for="email" type="format"><span class="error">Please check your email address</span></perch:error>
    </div>

    <div>
        <perch:label for="arrival">Desired arrival date</perch:label>
        <perch:input type="text" id="arrival" required="true" label="Arrival date" value="<perch:content id="date" />"/>
        <perch:error for="arrival" type="required"><span class="error">Please enter a desired arrival date</span></perch:error>
    </div>

    <div>
        <perch:label for="number_of_nights">Number of nights</perch:label>
        <perch:input type="select" options="1,2,3,4,5,6,7,8,9,10,11,12,13,14" id="number_of_nights" required="true" label="Number of nights" />
        <perch:error for="number_of_nights" type="required"><span class="error">Please enter the number of nights you wish to book</span></perch:error>
    </div>

    <div>
        <perch:label for="booking_type">Desired booking type</perch:label>
        <perch:input type="select" id="booking_type" options="Double|double,Twin|twin,Cottage|cottage" required="true" label="Booking type" value="<perch:content id="type" />"/>
        <perch:error for="booking_type" type="required"><span class="error">Please indicate the type of booking you wish to make</span></perch:error>
    </div>

    <div class="contact-field">
        <perch:label for="contact">Leave the next field blank</perch:label>
        <perch:input type="text" id="contact" antispam="honeypot" />
    </div>

    <div>
        <perch:label for="message">Message</perch:label>
        <perch:input type="textarea" id="message" required="false" label="Message" />
        <perch:error for="message" type="required"><span class="error">Please add a message</span></perch:error>
    </div>

    <div>
        <perch:input type="submit" id="submit" value="Send" />
    </div>

    <perch:success>
        <perch:content id="success" type="textarea" label="Thank you message" textile="true" editor="markitup" />
    </perch:success>
</perch:form>

Can you spot anything wrong? I've done an email test, and received the test email, so email can be sent.

Paul Bell

Paul Bell 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Do you have any server side redirects that could affect the page the form posts to?

Ah, I think that may be it - here's the htaccess (which removes .php)

RewriteEngine On

# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]

# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]

Can I modify the htaccess to not redirect if I'm submitting post data? Or could I modify the action of the form so it doesn't need to redirect? (from /book.php to "/book").

Update - I have just manually added the action for the form, and it now works as expected. I Googled the issue, and found that I'd previously already asked this question (https://forum.grabaperch.com/forum/04-09-2015-forms-app-and-removing-the-php-extension). Must be getting old...

Drew McLellan

Drew McLellan 2638 points
Perch Support

Great.