Hello to the whole community, I have a simple doubt, what is better to put the PHP code of a form within the same form or create another file where is the PHP code that will process the form?
Hello to the whole community, I have a simple doubt, what is better to put the PHP code of a form within the same form or create another file where is the PHP code that will process the form?
As you have been told by pure organization, it is better to keep them in different files.
Imagine that you need to modify some of the PHP logic, it is easier to read the code in a single PHP file than in one where the whole HTML & PHP.
In addition to correcting incidents in the code, it is also advisable to have it separated.
But it may be that for convenience, it may be better for you to have it all in one, so there is no black and white answer in this matter either.
For me it is much better to separate the server part (php) with the client part (the form). Why? If you separate the logic on the one hand (php) of the presentation (html) it is much easier to maintain the code than if you have it all together. In addition, it is much easier to read the code.