Welcome Guest ( Log In | Register)



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Stop Double Post/submit
eskimmer
post Aug 17 2007, 08:30 AM
Post #1


Newbie [Level 1]
*

Group: Members
Posts: 21
Joined: 15-August 07
Member No.: 48,203



Hi

Whats the best way of stopping a double post from occurring? Re-directs?

I was hoping that there was another way because I am using smarty and with the current setup of my site implementing redirects would be a right pain.

Thanks for any help.
Go to the top of the page
 
+Quote Post
truefusion
post Aug 17 2007, 12:45 PM
Post #2


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,868
Joined: 22-June 05
From: The World of Gentoo
Member No.: 8,528
T17 GFX Crew



Redirects will not stop double posting, for the info will still get submitted, and if the user has a connection problem and hits Send or Submit twice, it may get submitted twice or more (depending on how many submits the user has committed). Redirects are only helpful to prolong spam from happening and maybe other unknown reasons. The stopping of double posts is either dependent on the submitters' side or the webdesigner's JavaScript (you know, those scripts that render buttons useless after one click).
Go to the top of the page
 
+Quote Post
ewcreators
post Aug 29 2007, 07:16 AM
Post #3


Member [Level 1]
****

Group: Members
Posts: 59
Joined: 28-August 07
Member No.: 48,983



Not sure if its useful but anyways,
Its better to use redirect/ header('location:...'); rather than keeping the code on the same page.
Even if the user has a connection problem its better to be a little more safe the sorry.
Go to the top of the page
 
+Quote Post
truefusion
post Aug 29 2007, 10:32 AM
Post #4


Ephesians 6:10-17
Group Icon

Group: [MODERATOR]
Posts: 1,868
Joined: 22-June 05
From: The World of Gentoo
Member No.: 8,528
T17 GFX Crew



QUOTE(ewcreators @ Aug 29 2007, 03:16 AM) *
Its better to use redirect/ header('location:...'); rather than keeping the code on the same page.

Like i said above you—redirects won't work, for that page is the page that inserts the data into the database. All you're doing is splitting the code up. When the user submits a post, they are not shown the "add reply" page again with the submit button under the mouse. You don't have to wait till the next page loads up or even return back to you, so long as the server has received the information sent from and by the browser and everything validates, it's going into the database regardless on whether or not the user got to see the redirect page. Therefore, JavaScript is the most convenient option. Or you could write a script that checks to see if the same post has been submitted already—this would truly eliminate double posting (but is less convenient for the programmer), for what if the user agent has JavaScript disabled?
Go to the top of the page
 
+Quote Post
ewcreators
post Aug 29 2007, 01:52 PM
Post #5


Member [Level 1]
****

Group: Members
Posts: 59
Joined: 28-August 07
Member No.: 48,983



QUOTE(truefusion @ Aug 29 2007, 06:32 AM) *
Like i said above you—redirects won't work, for that page is the page that inserts the data into the database. All you're doing is splitting the code up. When the user submits a post, they are not shown the "add reply" page again with the submit button under the mouse. You don't have to wait till the next page loads up or even return back to you, so long as the server has received the information sent from and by the browser and everything validates, it's going into the database regardless on whether or not the user got to see the redirect page. Therefore, JavaScript is the most convenient option. Or you could write a script that checks to see if the same post has been submitted already—this would truly eliminate double posting (but is less convenient for the programmer), for what if the user agent has JavaScript disabled?


Well i just thought of another alternative :
how about using
if/else combined with mysql_affected_rows?
that could help
if it is one..then proceed , if it is more than it will stop the script and display an error message,
and then he can use a redirect. So if the user clicks more than once, he will get errors.
Go to the top of the page
 
+Quote Post
galexcd
post Sep 6 2007, 07:34 PM
Post #6


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
*********

Group: [HOSTED]
Posts: 975
Joined: 25-September 05
From: The dungeon deep below the foundation of trap17
Member No.: 12,251



On my forums I just have it set so you can't post more than once every 20 seconds. This prevents sombody who has a bad connection or accidently presses submit twice from actually sending the data twice becasue the second time would result in an error because that user just posted data less that 20 seconds before.
Go to the top of the page
 
+Quote Post
reconraiders
post Sep 6 2007, 10:56 PM
Post #7


Super Member
*********

Group: Members
Posts: 221
Joined: 6-June 07
Member No.: 44,288



Depending on your forum system that you use, you might be able to find a plugin that will MERGE double posts by the same user. I know I have this plugin installed on my forums using MyBB system. You can even adjust settings like how much time between posts it has to be for them to be merged or what to use to separate the merged posts (<hr /> or something). Of course, if there isn't a plugin available for your software, you could always make one yourself wink.gif
Go to the top of the page
 
+Quote Post
galexcd
post Sep 7 2007, 04:13 PM
Post #8


Define:EVIL PROGRAMMER (ē'vəl prō'grăm'ər)- n. An organism that converts caffeine into evil software.
*********

Group: [HOSTED]
Posts: 975
Joined: 25-September 05
From: The dungeon deep below the foundation of trap17
Member No.: 12,251



Well the problem with merging is if the user accidentally submitted the post twice the post would have the same text written twice in it, which in my opinion would be kind of inconvenient for the user to have to go back and edit it, but I guess it would be his fault in the first place that he clicked on the submit twice happy.gif But I don't know, if eskimmer is a php coder, he should be able to write his own solution probably based on some of the ideas some of us members have provided for him.
Go to the top of the page
 
+Quote Post
reconraiders
post Sep 7 2007, 09:11 PM
Post #9


Super Member
*********

Group: Members
Posts: 221
Joined: 6-June 07
Member No.: 44,288



QUOTE(alex7h3pr0gr4m3r @ Sep 7 2007, 12:13 PM) *
Well the problem with merging is if the user accidentally submitted the post twice the post would have the same text written twice in it, which in my opinion would be kind of inconvenient for the user to have to go back and edit it, but I guess it would be his fault in the first place that he clicked on the submit twice happy.gif But I don't know, if eskimmer is a php coder, he should be able to write his own solution probably based on some of the ideas some of us members have provided for him.


Well that's why there is the time limit between posts. Two things are happening...
1. The user is not allowed to submit more than one post within a certain amount of time (30seconds or so)
2. If the last post is by the user that is posting now, the two posts will be merged.

That should pretty much cut out all the double posts. I'm sure there might still be some crazy circumstances that will allow double posts, but if you do those two things you pretty much prevent them.