Page 1 of 1
Deleting, then refreshing page deletes next post as well
Posted: Thu May 06, 2010 12:55 pm
by Judy
Script URL:
Version of script: 1.7
Hosting company: Hostmonster
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution: Delet*
Write your message below:
If I delete a post, then refresh the guestbook page with the small "message has been deleted" informational message that appears, I find that the next post is deleted as well. This is in Firefox 3.6.3.
I don't want to delete posts just by refreshing the page! Is there a way to control that behavior?
Posted: Sun May 09, 2010 6:10 am
by Judy
Anyone?
Can someone at least confirm whether or not this behavior is replicated in other implementations?
1. Delete a post.
2. View the guestbook with "post has been deleted" message.
3. Refresh page.
Did you lose a post that you didn't expect to lose?
Posted: Sun May 09, 2010 7:26 am
by Henrie
Hello Judy,
I just tested and can confirm your findings.
Furthermore, each time I refresh the page when the "post has been deleted" message is shown, I lose another message.
This is indeed an unwanted (and dangerous) behaviour and hopefully Klemen knows a way on how to change this behaviour.
Greetings,
Henrie
Posted: Sun May 09, 2010 7:37 am
by Judy
Thank you, Henrie.
Posted: Sun May 09, 2010 11:06 am
by Klemen
This is expected behaviour, because GBook posts don't have assigned IDs but get deleted by line numbers. So if you click on "a=delete&num=0" it will always delete the first line in the entries.txt file.
Posted: Sun May 09, 2010 2:20 pm
by Judy
But I'm not, Klemen. Henrie -- please explain?
Posted: Sun May 09, 2010 2:41 pm
by Klemen
GBook entries are stored in lines in the entreis.txt files. To delete an entry GBook actually deletes a line from the enires.txt file.
If you refresh the page your browser submits the command to delete the line you just deleted again to GBook so that line is deleted again.
Example: if your entires file has 5 lines:
AAAA
BBBB
CCCC
DDDD
EEEEE
You decide to delete one post (for exampl ethe 2nd post), GBook will delete line 2. The result will be:
AAAA
CCCC
DDDD
EEEE
Because you refresh the page and click the "Retry" button the browser again sends request to delete 2nd line, so the 2nd line is deleted again. The result is:
AAAA
DDDD
EEEE
If you refreshed again, it would again delete 2nd line:
AAAA
EEEE
and so on...
Posted: Sun May 09, 2010 3:10 pm
by Judy
See
http://www.dweephor.com/images/gberror.jpg .
There is absolutely nothing to indicate to the user that another post will be deleted if this display is refreshed. And then another ... and another ...
Posted: Sun May 09, 2010 6:07 pm
by Judy
If you could let me know what's generating the "Selected entry was successfully removed!" message, at least I could alter it to caution the user not to refresh the page.
Posted: Sun May 09, 2010 11:15 pm
by Henrie
@
KlemenKlemen wrote:This is expected behaviour, because GBook posts don't have assigned IDs but get deleted by line numbers. So if you click on "a=delete&num=0" it will always delete the first line in the entries.txt file.
Judy and I are saying that after the line in gbook.txt has been deleted the GBook shows the guestbook again with the message "Selected entry was successfully removed!". The address bar of the browser shows only the address
http://www.mywebsite.com/gbook/gbook.php. So it is not clear that on refreshing the page it will send "a=delete&num=0" again.
I think Judy is right and that the current behaviour is not expected. I understand that the browser (in my case FF warns me that it resubmit previous data requests) will delete the data on resubmitting even though it is not indicated by the address bar. But still I think this is unwanted behaviour. Maybe you could introduce an extra step in the process of displaying the "Selected entry was successfully removed!" message so that on refreshing the page it will not delete another entry but just refreshes displaying the page.
@
Judy
You can write the warning message yourself. Change in the file language.inc.php line
Code: Select all
$lang['t37']='Selected entry was successfully removed!';
to something like
Code: Select all
$lang['t37']='Selected entry was successfully removed!<br />Don\'t click refresh as it will delete another entry. <a href="gbook.php">Click on this text</a> or the \'View guestbook\' link to stop deleting messages.';
Greetings,
Henrie
Posted: Sun May 09, 2010 11:26 pm
by Judy
"Maybe you could introduce an extra step in the process of displaying the "Selected entry was successfully removed!" message so that on refreshing the page it will not delete another entry but just refreshes displaying the page."
That would be perfect, Henrie. My browser doesn't warn me; I simply found one less post each time I would refresh the guestbook display. If there is an action tagged to the display of the "successfully removed" entry to end the deletion process, the issue would be solved.
In the meantime, I'll change the wording so the other moderators don't make that mistake. Thank you for the instructions.
resfreh problem
Posted: Mon May 10, 2010 11:06 am
by Willem
Like Judy and Henrie i encountered the same problem.
The same happens also after adding a new entry.
After refresh every time the last added entry is added again
I would like to find a way to prevent this to prevent a polution of my guestbook.
Anyone suggestions?
Posted: Tue May 11, 2010 3:05 pm
by Klemen
This was introduced to skip a separate confirmation page (a "your post has been submitted/deleted ... click to continue" page).
But yes, I see why it's a problem and will include a check to just show the main guestbook page on refresh in future versions.