![]() |
How to clear POST data after processing?? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How to clear POST data after processing?? (/showthread.php?tid=27767) |
How to clear POST data after processing?? - El Forum - 02-19-2010 [eluser]123wesweat[/eluser] Each time i reload the page it keeps sending the data into the db. So how can i clear the $_POST??? Code: $res = $this->form_model->insert_data(); How to clear POST data after processing?? - El Forum - 02-19-2010 [eluser]mikelbring[/eluser] What I sometimes do is redirect the user to the returned page after doing what is suppose to be posted. But I am sure there is a better solution. Interested in knowing what. How to clear POST data after processing?? - El Forum - 02-19-2010 [eluser]danmontgomery[/eluser] Code: $_POST[] = ''; This wouldn't clear any array, it just appends a blank string to the end of it. Code: unset($_POST); unset($_REQUEST); Should work... mikelbring's reply works just as well too. How to clear POST data after processing?? - El Forum - 02-19-2010 [eluser]mikelbring[/eluser] Hes worried about someone refreshing and being able to resubmit the post. I do not think unsetting them will work, but I haven't ever tried it either. How to clear POST data after processing?? - El Forum - 02-19-2010 [eluser]danmontgomery[/eluser] Ah, then yes, you would have to redirect. How to clear POST data after processing?? - El Forum - 02-19-2010 [eluser]mikelbring[/eluser] Problem I see is thats creating a 301 redirect overhead. Maybe there is some http-header magic you can do. How to clear POST data after processing?? - El Forum - 02-19-2010 [eluser]bretticus[/eluser] Doing a redirect is pretty standard actually. However, you could also do a duplicate record query before committing the insert. There is no state in HTTP, you can't just clear POST. |