[eluser]eedfwChris[/eluser]
[quote author="PoWah" date="1189275777"]Hi again, guys.
I think, now I have very simple question for advanced programmers. How can I prevent repetitive inserts into DB (with identical data) when a user manually refreshes a page after a valid form submission?? I tried after form submission to unset $_POST variable but no results :/ I'm feeling dummy about this question :red:
p.s.: form's action link points to itself[/quote]
Just an insight $_POST variables are unset by CI by default so unset($_POST) wouldn't help anything. Also, when a user hits refresh it is in fact resetting the same $_POST data.
Also, redirecting is not a true solution because the user could easily hit "back" a few times and the browser would ask you to resubmit the form data.
Okay, with all that said what you COULD do is assign a sort of "form session"
1) When creating a form set a unique "form session" id (some random string) in the user's session.
2) Set inside the form params (a hidden field) that same unique "form session" id.
3) Upon submission check to make sure the "form session" id in the form and the session match.
4) If they do match then add the data to your db and then change (or unset) the "form session" id.
Viola!