Answer the question
In order to leave comments, you need to log in
PHP. How to make form and handler in one file?
Hello. I am slowly improving my knowledge of PHP.
Asked a question.
For example, we have /guestbook/form.php/ In which there is a form with fields "Login, Text".
How to make this form handler in the same file? In what ways?
A native question, but I don’t even know how to ask Google about it.
Thank you.
Answer the question
In order to leave comments, you need to log in
It’s probably better to just separate everything normally, based on the MVC pattern, to avoid mess, but you can also write in the action the form parameter the path to the same PHP script that created the form, and then, based on the request type, determine which part run code.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question