phpMyEdit - Viewing Bug Advanced Details [ Go Back ]
284 documentation feature always 2004-11-27 18:57 2004-11-27 22:02
marianov Firefox  
Linux  
normal  
acknowledged 5.4 (stable)  
open  
none  
none  
Browser refresh causes duplicate inserts.
When the user clicks refresh on the browser after an insert PME inserts a duplicated record in the table.
I havent found a way to avoid it (aside from using a unique index, which is not always posible).
In other php apps i have used something like:


if (!isset($_SESSION['pcount']))
$_SESSION['pcount'] = 0; //$pcount is a "form post counter"

function formrefresh() { return $_REQUEST['pcount'] !=
$_SESSION['pcount']++; }

and then when building each form I add:
<input type=hidden name=pcount value=<?=$_SESSION['pcount'] ; ?> >

So before taking action I can check that the user is not submitting a form like this:

if (!formrefresh() ) {
//insert the record
} else {
// show a new empty form or redirect to the list of records
}

Do you think it would be easy to add this kind of feature to PME ?

Thanks,

Mariano

Bug Notes
michal   
2004-11-27 20:31   
[this is not website/homepage related, more docuemntation issue.]

yes,

have a look at trigger insert before (to stop the insert proccess), and $opts['cgi']['persist'] option (to keep the hidden variable).
nepto   
2004-11-27 21:55   
Well, concerning to addition of this into core class, I do not thing it is a good idea. I do not want to mess/bloat core class with things like $_SESSION and so on.

upravené: 2004-11-27 21:57
hbernard   
2004-11-27 22:02   
Agreed.

This is (as michal said) a documentation issue.