php - Same form, different pages
I have a simple form, and when i submit the information, i insert it on my DB. Until here everything is ok. But i need to have the same form on 20 pages. I know i could replicate the code, or even use different buttons to get the result i want. But i want to know if there is a better way to use the same form, and identify the page where i submit the information. So that the information on my DB could be:
ID Page Name Email Text and so on...
Thank you in advance. Best Regards.
"Maybe i didn't explain myself well, and i'm not asking for "free coding service" as someone said. I know i can , in the different pages. That is what i'm doing. Also the information is being inserted on my BD when i submit. No problem until here! What i want to know, is how can i have my form being include on the different pages, using the same "submit" button with the same name, but when the information is inserted on my BD, i can know that my column "page" gets the right information from the different pages."
Answer
Solution:
Something that I use for every website I create, is building my own "Template" page in the root folder, and create a page like index.php etc . in the same root folder.
In those "page" files I include everything that i need. Inside the root folder I have a content and classes folder.
The "content" files contain things that will be shown on the page and the menu that I need on many pages, and I use the class files for things that need to be handled, like DB connection and form handling.
Example of me including content inside the template page between the
<body></body>
tagsAnd the example of index.php
Using this method makes everything less time consuming because easier to change one thing for multiple pages that are basically the same.
You can use this for example for your form.
Answer
Solution:
I would make a class that in turn calls a template.
The class will hold properties appropriate to its instantiation and can be as flexible as needed. The template will be called from this class.
You can then instantiate it on your pages as something like:
of course I did not write out the class for you, but it is simple enough and my answer fits the question for level of detail.
I hope it helps.
Answer
Solution:
Ok, i figure it out!
If i use:
I can get the result i want.
Thank you anyway! :)