Forum

Thread tagged as: Problem, Error, Blog

Blog Comments Don't Get Posted

Whenever you try to post a comment on a blog post it doesn't appear on the admin area or on the website. Also, the success message doesn't appear either. I even checked phpMyAdmin and everything is setup correctly so I don't know why comments aren't being posted. Please help!

Diagnostic Information

Perch: 2.8.4, PHP: 5.4.37, MySQL: mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.4), assets (2.8.4), categories (2.8.4), perch_blog (4.6)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog' );
PERCH_LOGINPATH: /perch
PERCH_PATH: /home/npsantini/public_html/santini_io/perch
PERCH_CORE: /home/npsantini/public_html/santini_io/perch/core
PERCH_RESFILEPATH: /home/npsantini/public_html/santini_io/perch/resources
Image manipulation: GD Imagick
PHP limits: Max upload 32M, Max POST 48M, Memory: 64M, Total max file upload: 32M
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /home/npsantini/public_html/santini_io
HTTP_HOST: santini.io

Comment_form.html

<perch:if id="postAllowComments" value="1">

    <perch:form id="comment" method="post" app="perch_blog" class="comment-form" action="<perch:blog id="postURL" />">
        <fieldset>
           <legend>Leave a comment</legend>
            <div>
                <perch:label for="commentName">Name</perch:label><br/>
                <perch:input type="text" id="commentName" required="true" label="Name" antispam="name" />
                <perch:error for="commentName" type="required">Required</perch:error>
            </div>
            <div>
                <perch:label for="commentEmail">Email</perch:label><br/>
                <perch:input type="email" id="commentEmail" required="true" label="Email" antispam="email" />
                <perch:error for="commentEmail" type="required">Required</perch:error>
                <perch:error for="commentEmail" type="format">Check format of address</perch:error>
            </div>
            <div>
                <perch:label for="commentURL">Website</perch:label><br/>
                <perch:input type="url" id="commentURL" placeholder="https://" label="URL" antispam="url" />
            </div>
            <div>
                <perch:label for="commentHTML">Comment</perch:label><br/>
                <perch:input type="textarea" id="commentHTML" required="true" label="Message" antispam="body" />
                <perch:error for="commentHTML" type="required">Required</perch:error>
            </div>
            <div>
                <perch:input type="hidden" id="postID" value="<perch:blog id="postID" />" />
                <perch:input type="submit" id="submitComment" value="Submit" />
            </div>

        </fieldset>
        <perch:success>
            <p>Thank you. Your comment has been submitted and will appear on the site once approved.</p>
        </perch:success>

    </perch:form>
</perch:if>

comment.html

<perch:before>
    <h2>Comments</h2>
    <ul class="comments listing">
</perch:before>
        <li id="comment<perch:blog id="commentID" type="hidden" />">
            <img src="//www.gravatar.com/avatar/<perch:blog id="commentEmail" type="email" label="Email" order="2" hash="md5" required="true" />?s=120&d=mm" width="60" height="60" />

            <div class="comment">
                <div class="commenter">
                    <perch:if exists="commentURL"><a href="<perch:blog id="commentURL" type="url" label="URL" order="3" />"></perch:if>
                        <strong><perch:blog id="commentName" type="text" label="Name" order="1" required="true" />:</strong>
                    <perch:if exists="commentURL"></a></perch:if>
                </div>
                <p rel="bookmark" class="date"><perch:blog id="commentDateTime" format="%d %b %Y %X" type="date" time="true" label="Date" /></p>
                <perch:blog id="commentHTML" encode="false" html="true" type="textarea" label="Message (HTML)" order="4" required="true" />
            </div>
        </li>
<perch:after>
    </ul>

</perch:after>

post.php (Note: This is only a snippet of the post.php page)

<?php perch_blog_post_comments(perch_get('s'));?>

<?php perch_blog_post_comment_form(perch_get('s')); ?>
Nick Santini

Nick Santini 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

If you turn on debug for the page and submit a comment, what happens?

I don't know if this has anything to do with it but this appears under a tab in the google chrome developer console:

Failed to clear temp storage: It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources. SecurityError

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you clear that error does it return?

No it doesn't.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's possibly not from Perch then.

OK I guess what I will have to do is reinstall it because I didn't see if the comments worked before changing the templates even though I don't think that is the problem.

I reinstalled the blog app and it still doesn't work. Is it possible that form action is wrong? Right now this what it is

action="<perch:blog id="postURL" />"

It just seems like it would need to be something else. Like a form handler not the page that the comment form was on.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If you turn on debug for the page and submit a comment, what happens?

Nothing. The page just refreshes without showing the success text and without actually posting the comment.

Drew McLellan

Drew McLellan 2638 points
Perch Support

And there's zero debug output?

Maybe I am doing that wrong. I hit f12 to go to the chrome developer console and then I go to the console tab which usually is where errors would be located the only error was the missing logo.

Drew McLellan

Drew McLellan 2638 points
Perch Support

This is the debug message from the post page after the comment was submitted.

Debug Message
SELECT * FROM perch2_blog_posts WHERE postStatus='Published' AND postDateTime<='2015-03-27 09:45:00' AND postSlug='2015-03-26-this-is-a-blog'
SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
SELECT * FROM perch2_blog_sections ORDER BY sectionTitle ASC
Using template: /addons/apps/perch_blog/templates/blog/post.html
SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 AND pageDepth >=0 AND pageDepth<=1 ORDER BY pageTreePosition ASC
SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/blog/post.php' LIMIT 1
Using template: /templates/navigation/item.html
SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_blog_index idx JOIN perch2_blog_posts main ON idx.itemID=main.postID AND idx.itemKey='postID' JOIN perch2_blog_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='postID' AND idx2.indexKey='_id' WHERE 1=1 AND ((idx.indexKey='postSlug' AND idx.indexValue='2015-03-26-this-is-a-blog')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID ) as tbl WHERE (postStatus='Published' AND postDateTime<='2015-03-27 09:45:00' ) GROUP BY itemID ORDER BY sortval ASC LIMIT 0, 10
SELECT FOUND_ROWS() AS `count`
Using template: /addons/apps/perch_blog/templates/blog/post.html
SELECT * FROM perch2_blog_authors ORDER BY authorFamilyName, authorGivenName ASC
SELECT * FROM perch2_blog_comments WHERE 1=1 AND postID=3 AND commentStatus='LIVE' ORDER BY commentDateTime ASC
Using template: /addons/apps/perch_blog/templates/blog/comment.html
SELECT * FROM perch2_blog_posts WHERE postID=3 AND postStatus='Published' AND postDateTime<='2015-03-27 09:45:00'
Using template: /addons/apps/perch_blog/templates/blog/comment_form.html
Drew McLellan

Drew McLellan 2638 points
Perch Support

That's strange - I can't see the form being posted at all.

Are you doing any server side redirects?

Not that I know of. This is my .htaccess code. I don't know if this has anything to do with it. If there is code that seems out of the ordinary, it is because the people over at godaddy added it as a fix because for some reason some people where not able to view my sites hosted with them. I hope this isn't the case but I have had problems in the past with my godaddy hosting.

.htaccess code

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/svg+xml "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 week"
ExpiresByType text/html "access 1 day"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 month"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

Options +FollowSymLinks -MultiViews +ExecCGI
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE image/png
AddOutputFilterByType DEFLATE image/jpeg
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

#AddHandler x-httpd-php5-3 .html
AddHandler fcgid-script .html
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .html
Drew McLellan

Drew McLellan 2638 points
Perch Support

You have redirects in place to strip .php extensions. What does the action on the comment form look like? Is it being caught by that redirect?

<form id="form1_comment" class="comment-form" action="/blog/post.php?s=2015-03-26-this-is-a-blog" method="post">
        <fieldset>
           <legend>Leave a comment</legend>
            <div>
                <label for="form1_commentName">Name</label><br>
                <input id="form1_commentName" name="commentName" type="text" required="required">

            </div>
            <div>
                <label for="form1_commentEmail">Email</label><br>
                <input id="form1_commentEmail" name="commentEmail" type="email" required="required">


            </div>
            <div>
                <label for="form1_commentURL">Website</label><br>
                <input id="form1_commentURL" name="commentURL" placeholder="https://" type="url">
            </div>
            <div>
                <label for="form1_commentHTML">Comment</label><br>
                <textarea id="form1_commentHTML" name="commentHTML" cols="30" rows="4" required="required"></textarea>

            </div>
            <div>
                <input id="form1_postID" name="postID" value="3" type="hidden">
                <input id="form1_submitComment" name="submitComment" value="Submit" type="submit"><input type="hidden" name="cms-form" value="Y29tbWVudDpwZXJjaF9ibG9nOi9hZGRvbnMvYXBwcy9wZXJjaF9ibG9nL3RlbXBsYXRlcy9ibG9nL2NvbW1lbnRfZm9ybS5odG1s">
            </div>

        </fieldset>
    </form>

That was the problem. I deleted the current .htaccess file in order to see if that was in fact the problem and it was.

Thanks for your help. You are the man!