Answer the question
In order to leave comments, you need to log in
How to submit a form to the same page?
If you need to process the form on the same page, you can do this: <form action="" method="POST">
But I saw examples where some global variable is put into action = "", I don’t remember exactly, from $ _SERVER like.
Why, what's the point, what's the right way?
Answer the question
In order to leave comments, you need to log in
$_SERVER['PHP_SELF'] is written. But I can't say that this is the best solution. But at your stage it should be enough.
The point is that an empty action is not valid. And different browsers may have different behavior. Someone will translate to the same page, and someone - to the index ...
Therefore, it is better to avoid such ambiguities
Put a link to the same document, and in the code check if the button is pressed if{ isset $post submit (I'm writing from the phone so something like this)} else{ showing the form}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question