Jump to content

How might I read from a mysqli database and store the data in a session please?

Recommended Posts



Apologies, if I've posted in the wrong forum.


What I would like to ask is.


I'm creating a simple login screen, and once the user's username and password is matched with what's held on the database.

I would like to store the user's fullname, email and membershiptype in a session so I can call it up in another php file later on.


At present, I'm able to connect and open the database, then read from it. Then I'm getting stuck.


I'm getting errors on lines:-

$member_members_id = $_REQUEST['member_id'];

$member_fullname = $_REQUEST['fullname'];


Could any one please help?


Thank You.




Link to post
Share on other sites

First I need to know what the error messages say. Error messages contain vital information required to solve the problem.


If I were you I would remove that file you just uploaded and replace it with something that has your database login information removed.


At a first look these things in your script need to be fixed:

  • session_start() must be before any HTML or echo statements on the page.
  • session_register() is deprecated. Just remove all those lines and just do normal $_SESSION assignments.
  • mysql_error() is deprecated and won't do anything since you're using mysqli in the rest of your code.
  • Your SQL query needs to be updated to select all the fields you want to store.
  • The data you're looking for is not in the $_REQUEST array, it's in the $row array which contains the information that was loaded from the database.
  • It is preferable to not use $_REQUEST. Use $_POST or $_GET depending on where your data is coming from.
Link to post
Share on other sites
  • 3 weeks later...

Hello Ingolme,


Thank you for your reply.

I've deleted the file, and walked way.

After a short break I've tried again, and have managed to achieve my goal.

But I don't know what I've done differently.


Thank you for your reply and help.


Kind Regards. :)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...