sql - Getting all info of the logged in user? PHP -


Hello

Can I get all the information from the user when he logs in and stores it To get the user's username, email etc., instead of having a piece of code at the top of all pages, the session will be logged in.

  $ userq = mysql_query ("Select * User from WHERE id = {$ _ Session ID ']} "); $ Auth_user = mysql_fetch_assoc ($ userq);  

Log in. PHP

  $ sql = mysql_query ("Choose where ID from user and username = '$ user name' and password = '$ password'"); If (mysql_num_rows ($ sql) & lt; 1) {echo "incorrect username / password"; } And ($ _SESSION ['id'] = mysql_result ($ result, 0, 'id'); header ("location: index.php");}  

Yes you (probably) .

To consider some things, though:

  • What you only need in the session (do not want to place a huge session file with many useless)
  • Updates the profile, you have to store new data in the database and in session - which means Some other works on the "Edit Profile" page.
  • If another user edits a user's profile (like an administrator) Will not be able to change the session data, and will be updated, the next time the user logs in when the database is loaded from the database.
    • If something happens that happens often, Refresh data from database Rana like

Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -