Design question load page parameters from DB

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
hybris
Forum Contributor
Posts: 172
Joined: Wed Sep 25, 2013 4:09 am

Design question load page parameters from DB

Post by hybris »

Hi,

I'm going to do a small webshop (yeah i know there are loads of free ones, Im doing this just to learn php better :) ) and I want to create a code where i store most page info (settings (like page width, height, button names, title and so on)) in a database so I can easily modify the settings if I want to create a new shop later on or maybe create a framework where users can design their own shops..

So I will make the page a class with variablles like
private $keywords;
private $title;
private $buttons; ... and so on.

Each time a user clicks on a button a new page will be drawn with new content.

My question is how will I do this in the best way. I do not want to do a database call (for the page settings anyway) everytime the page loads (only the first time every session).

Should I store the values in session info after initial call to DB and check with isset later on or are there any better way to do this?

Thanks in advance.

Edit: Oh and how secure is the session info? Say I have users with a userlevel that sets permissions.. can I store userlevel in session info or is it better to do a db call for userinfo when trying to access admin functions? /edit
User avatar
Christopher
Site Administrator
Posts: 13595
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Design question load page parameters from DB

Post by Christopher »

Probably the best way to let users can "design their own shops" is to build an editor to customize the stylesheet. You could save the settings in a database somewhere, but it would be best to write a local stylesheet file when they save the settings. If well thought out, the user would be able to highly customize the look of the site -- yet the code and HTML would all stay the same.
(#10850)
hybris
Forum Contributor
Posts: 172
Joined: Wed Sep 25, 2013 4:09 am

Re: Design question load page parameters from DB

Post by hybris »

Hi and thank You,
yeah but still every time i update the page it will read either the file or db whereever i put the info (I just realized the session is stored as a temp file so it will read from a file no matter what... I guess Im really wondering if its possible to cache parts of the page like menus that will not change..
(the left and top menu will not change so only content that is going to be updated with user actions is the bottom right div)... Is it worth bothering with this at all or should I just make a css file and reload the whole page everytime a user clicks on a button or link?

Also I'm on a webhotel (one.com) so I guess its hard to cache stuff to memory.. maybe I could do it if I had a private server..

Since it will be a webshop I'm extra concerned with the safety... do You guys think the temp session files is secure enough at a place like one.com or should I do my own session functions and store the sessions in a db.. Do You have any experience with that (pro/cons).

Sorry if this is not advanced enough for this forum if so please move it to a more apropriate forum.
User avatar
Christopher
Site Administrator
Posts: 13595
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Design question load page parameters from DB

Post by Christopher »

hybris wrote:Hi and thank You,
yeah but still every time i update the page it will read either the file or db whereever i put the info (I just realized the session is stored as a temp file so it will read from a file no matter what... I guess Im really wondering if its possible to cache parts of the page like menus that will not change..
(the left and top menu will not change so only content that is going to be updated with user actions is the bottom right div)... Is it worth bothering with this at all or should I just make a css file and reload the whole page everytime a user clicks on a button or link?
That was my whole point for suggesting generating a stylesheet. Since the site styles will be updated infrequently they are mainly read-only. The browser will do great caching for you since they are a separate file from you pages. This is even more helpful from database driven sites that are less cache-able.
hybris wrote:Also I'm on a webhotel (one.com) so I guess its hard to cache stuff to memory.. maybe I could do it if I had a private server..

Since it will be a webshop I'm extra concerned with the safety... do You guys think the temp session files is secure enough at a place like one.com or should I do my own session functions and store the sessions in a db.. Do You have any experience with that (pro/cons)..
If you are doing e-commerce on a shared server then be very careful what you save in the session. Do not put credit card numbers in the session. I would actually recommend that you do not save credit card numbers anywhere on your systems -- just send them via HTTPS to the payment processor and then clear them from all variables.
(#10850)
Post Reply