| | 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. |
|
|
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).
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. 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?
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.
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.
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
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
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 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.
The only way you're going to stop double posting is if you stop clicking the post button twice. If you don't do this, you'll never have a double post. A notice can do that very easily, although sometimes I doubt that people will read those notices
Recent Queries:-
Keywords : submit
This can be considered my first php page after a long while, I did a little basic php years ago and Hi all i want make one form whit php , when users submit there urls , then my site give one picture Hey me again. Looks like im having trouble with php. THis time the solution should be easy but i Looking for stop, double, post, submit
|
|
![]() Stop Double Post/submit |
| ADD REPLY / Got an Opinion! | a humble request :-) | RAPID SEARCH! | Free Hosting | [X] |
|
Express your Opinions, Thoughts or Contribute more info. to help others. Ask your Doubts & Queries to get answers, So that "Together We can help others!" |
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP. | 500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE |
|