Hi All;
I have a form (which make a search for some data based on the selections and so on), I need to use this form in alot of pages, but it is not practical to keep put the code in each of these pages, and if I did any change on the code then I have to copy this code for all the pages ... it is really hard work.
Any suggested method to be placed in one place and use it in different pages, so I maintain it in this place only without need to keep copy for each change?
Any help?
Regards
Bilal
Same code to be used in multiple pages
Moderator: General Moderators
Re: Same code to be used in multiple pages
Generally you'd use a function. You can make php code to run a section of HTML, using echo's - and you can then make this an include.php file, and just include this file at the top of your page and run the function in a section of php where you need it.
functions basics
functions basics
Re: Same code to be used in multiple pages
aravona's suggestion can be simplified by taking a more direct approach and placing the include statement where the form is to be inserted. Additional functions and echo statements are unnecessary.
PHP Manual: include()
Edit: This post was recovered from search engine cache.
PHP Manual: include()
Edit: This post was recovered from search engine cache.