Hello,
I have an account page and I would like user informations (stored in mysql) if the user is logged in.
I'm using php to retrieve the data and displaying them into the account page.
Php is embedded in the account page, so everytime the user visit to the account page the data are retrieved from the database.
Is this correct ? Is it reasonable ? Or should I optimize the code in order to retrieve the datas only once from the database ?
thanks
question about optimizing access to mysql
Moderator: General Moderators
Re: question about optimizing access to mysql
If i understood what you were doing correctly, it sounds very reasonable 
Re: question about optimizing access to mysql
Not sure if this what u want, but u could use sessions to give access to certain pages to your users. Just check with isset($_SESSION['username']), and if its not redirect to another page. You only retrieve the details from the DB once.
Hope this helps
Hope this helps
Re: question about optimizing access to mysql
all right!
so if I've understood well,
every time I access to account page
- I check if the user i loged in
- i check if the data are stored in session variables
- if they are not stored, I retrieve them from mysql and i store them in php variables
so if I've understood well,
every time I access to account page
- I check if the user i loged in
- i check if the data are stored in session variables
- if they are not stored, I retrieve them from mysql and i store them in php variables