I have a POST form where of course there is things in it that you need to submit. when I submit it I usually submit them to another file for example action.php. Now here is my question: after submitting the file and after all the operations that user wanted are done how do you usually deal with the situation? do you redirect back to the previous page? if so, how can you show that the operation the user wanted are executed and there is no error?
to be more specific look at the following code:
if ($_POST['something']) {
$doeverything
if $doeverything
{
what do you usually put here? how can I show a message here, in the same time, I am back to the previous page where I submitted my information in.
}
how can I assign an error after redirecting back?
You can do this using the PHP sessions. When you finish your work in
action.php, you store the message in session like$_SESSION['message'] = 'Completed'and you can redirect to previous page. In the page where you have submitted your form, you can show the message using the session like echo$_SESSION['message']Another way may be using
$_GETsuper global variable. You can redirect to previous page usingredirect_to('previous_page.php?success=yes').In previous page you can check the value of$_GET['success']and if it is yes you can echo ‘Your form is successfully submitted’