We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Data is inserted twice after a page refersh

Hi guys,

I have a problem about data insertion in my database table. when i refresh my page after form submit it duplicates the first one. Is there any way to prevent this without comparing the data if it is present already in the database or by not redirecting the user to other page. What i want is the user will stay on same page.

Thanks



7.9k

check your browser plugin, my chrome alse experienced same problem but firefox run fine



55.9k
Accepted
answer

$this->response->redirect('controller/action');

saves my day :)

Have you tried setting database table columns as Unique

@Dominic Kinyanjui i havent yet, is setting table column to unique will prevent this kind of issue?

@Dominic Kinyanjui i havent yet, is setting table column to unique will prevent this kind of issue?

This will work but only if your column fields will not be null