chinoknot Posted November 13, 2015 Share Posted November 13, 2015 Hello,this time I'm in trouble. Seriously. I need to do a one page which collect all the functions contained in 3 page with query and other stuff, after 2 days I'm a litlle bit confused and blocked, so I need your help.The "old" page was "menu", containing the menu, header and graphic informations, then "preleva", which take record from a table with a certain criteria and "registrazioni" which insert the data in the table plus display all the information on screen from the table. The result should be: from a call/event, which call my only page who read the table, select the right record and then insert in the table. Try to see the files, if you can help me I appreciate so much.My new page is menu_new. I can read the right record, but after I have problem with all the criteria of the old "preleva". Registrazioni.php menu.php menu_new.php Preleva.php Quote Link to comment https://forums.phpfreaks.com/topic/299467-make-one-page-php-from-3-page/ Share on other sites More sharing options...
mac_gyver Posted November 13, 2015 Share Posted November 13, 2015 in order to make a single page web site, you need to separate the 'concerns' in your code. the post method form processing code is a separate concern from get method code that produces content for your page. the get method code can also be separated into 'business' logic that knows how to retrieve data, and stores the data in php array variables, and 'presentation' logic that knows how to produce the output using the retrieved data, and stores the produced output in php variables. the output that's produced from the 'presentation' logic should just be echoed at the correct place in your html document or output as a response to an ajax request. after you separate the code, for each different functionality you want on a page, into its separate concerns (some functionality may not have all three parts), you would group all the different post method form processing code together, all the get method 'business' logic together, and all the get method 'presentation' logic together. post method forms and post method form processing code should ONLY be used when you are submitting data to the server for creating/inserting data, updating/editing data, or deleting data. get method forms/links and get method code is for determining what the page will display. your code is apparently using a post method form to determine what to display on the page. you would need to fix this first. all the post method form processing code needs to come before you output anything to the browser, so that you can do a header() redirect after successfully processing the form data, to cause a get request for your page. the get method business/presentation logic should actually be before the <!DOCTYPE tag. see the following post for a suggested layout for the code on your page - http://forums.phpfreaks.com/topic/297824-database-issues-and-working/?do=findComment&comment=1519095 it also appears that your code is repeatedly making a database connection, running queries, and closing the database connection. your single page should make one database connection, then pass it into (functions/classes) any code that needs to use the database connection. if you follow the suggested page layout at that linked to post, there are specific places listed where you would make the database connection and close it. Quote Link to comment https://forums.phpfreaks.com/topic/299467-make-one-page-php-from-3-page/#findComment-1526345 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.