Jump to content

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


IChaps

Recommended Posts

Hello.

 

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 comment
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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...