Is it ok or standard to use $_SERVER['PHP_SELF'];
and header('Location: http://www.example.com/form.php');
in the same page to avoid resubmitting the form on refresh.
I understand the concept of using $_SERVER['PHP_SELF'];
on a page with a form, but then if I use header('Location: http://www.example.com/form.php');
to avoid resubmitting to the db should I be redirecting to the same page.
I'm kinda confused.
UPDATE: Making it a bit more clear
I don't want to use the processing file name in form action (future proof - filename change, etc.), hence the use of $_SERVER['PHP_SELF']
but now hitting refresh resubmits the form. To avoid that we go the PRG route, but redirecting it to the same page $_SERVER['PHP_SELF']
is not solving the issue.
I wonder how others are doing it. Bottom line, I want to have my form and processing it in the same page without resubmission on refresh.