This is the community forum. For a developer response use the Client Area.
Follow us on Facebook, Twitter and YouTube!

Resubmit on "back" click
#1

Hi!

First of all, I love what is being done with commentics. Thanks for such a great tool. I had some problems (which I will get to in another post), but for now I want to try to change one thing.

What should I change, so that after a comment is submitted, and a user presses "back", they don't resubmit that comment again? I saw a tip that mentioned using the captcha tool, but in my case I really don't want to use it (and for some reason it also isn't working).

I have an idea what I can do, is, when the comment is submitted, go to another page, which then does some PHP header location, back to the real page. I think I did something like that before, but just wondering if someone has a quick easy fix before I get messy with things.

Please let me know and thanks again!

-Peter
Reply
#2

Hi,

I just submitted a comment on my test site without captcha enabled, I hit the back button, the browser (Firefox) asked whether I was sure that I wanted to resend the data and I confirmed, I got an error message from Commentics saying that my last comment was submitted recently and that I should wait longer. When I submitted a comment and refreshed the page instead of clicking the back button I also got the same error message.

In Internet Explorer if I click the back button then the browser just displays a page saying that the webpage has expired. If I click refresh then I get the Commentics error message.

Maybe you are detected as the admin so the flooding isn't being checked?

Have you completed the interview?
Reply
#3

Hi,

No, I have my comments allowable every 5 seconds or so (low), and about 60 per hour (for instance). Even if it was set to 1 minute, there is a chance of it happening, if they stayed on the page for a minute, then hit back (you can try and see). Also supposing they get the "do you want to resend data" message, the person will have to click yes, because after trying both yes and no, they will see that "no" yields them a blank page (non-functioning website). Hope it makes sense.

-Pete

(21-Dec-2010, 11:18 AM)Steven Wrote:  Hi,

I just submitted a comment on my test site without captcha enabled, I hit the back button, the browser (Firefox) asked whether I was sure that I wanted to resend the data and I confirmed, I got an error message from Commentics saying that my last comment was submitted recently and that I should wait longer. When I submitted a comment and refreshed the page instead of clicking the back button I also got the same error message.

In Internet Explorer if I click the back button then the browser just displays a page saying that the webpage has expired. If I click refresh then I get the Commentics error message.

Maybe you are detected as the admin so the flooding isn't being checked?

Reply
#4

I have written a solution which you might prefer to a redirect. When a comment is submitted, the script adds the comment to the browser session. If that same comment is submitted again then the script displays an error message. This works both when clicking the back button and refreshing the page. This should prevent repeat comments for the duration of the session which should be about 24 minutes. I suppose I could use a cookie instead if a longer solution is required.

Have you completed the interview?
Reply
#5

That sounds awesome! Is it part of the commentics package now? If not can you paste some uber-code - I can figure it out Smile If it is part of the package can you direct me to what parts I need? The thing is I have modified a few of the commentics files in the past two weeks, and would rather paste the new stuff in, before I completely re-modify the new version you will be releasing in a few months.

And last but not least, is there a way to donate $ to your project?

Thank you
-Pete
Reply
#6

Here is the code to paste (It will be included in the next version).

I will send you a PM shortly with information about how to donate to the project.

In comments/includes/app/processor.php

Find this line (284):
PHP Code:
<?php 
$comment
= sanitize($comment, false, false, true); //complete sanitization

And paste this after it:
PHP Code:
<?php 
if (isset($_SESSION['comment']) && $_SESSION['comment'] == $comment) {
error("You have already submitted this comment.");
}

Then find this line (403):
PHP Code:
<?php 
notify_admin_new_comment_approve
($name, $comment, $page_id); //notify admin of new comment

And paste this after it:
PHP Code:
<?php 
$_SESSION
['comment'] = $comment;

Then find this line (442):
PHP Code:
<?php 
notify_admin_new_comment_okay
($name, $comment, $page_id); //notify admin of new comment

And paste this after it:
PHP Code:
<?php 
$_SESSION
['comment'] = $comment;

Have you completed the interview?
Reply
#7

Looks easy! Will try it out now, thank you very much!

-Pete

Reply
#8

Works! That was really easy, and a nice addition to your already awesome system. Thanks a ton!
Reply
#9

You're welcome. Thank you for the donation Smile

Have you completed the interview?
Reply


Possibly Related Threads…
Thread / Author Replies Views Last Post
Last Post by Steven
04-Nov-2012, 01:47 PM

Forum Jump:


Users browsing this thread: 5 Guest(s)