I have created a login system based in PHP and MySQL, where upon registration, users enter the information required in the form. However, there is another page where they can review their information once they have logged in. I am new to PHP but I would like to know the code to show the user their OWN information and no other information from any other user. Thanks in advance...let me know if I have to be more clear.

Recommended Answers

All 7 Replies

Once the user is registered and in the database, and have logged in you can make a call into the database for that selected user by some sort of requirement. I.E.

SELECT * FROM User WHERE userid = '1'

The above code my requirement is that the userid must be one. With PHP involve something like this

SELECT * FROM User WHERE username = "$_POST['username']"

WIth the above example I'm using what the user inputed as their username as my search requirement.

Member Avatar for P0lT10n

You can serch another thing like the email entered, or the same primary key of your database

Once the user is registered and in the database, and have logged in you can make a call into the database for that selected user by some sort of requirement. I.E.

SELECT * FROM User WHERE userid = '1'

The above code my requirement is that the userid must be one. With PHP involve something like this

SELECT * FROM User WHERE username = "$_POST['username']"

WIth the above example I'm using what the user inputed as their username as my search requirement.

Sorry to be a bother.....It worked, however, I would like my users just to get an overview of their own information. How would I display information belonging to the user to that particulat user. ie. ( if the table in MySQL had the following values:

First name Last Name Age Gender
Bob Jones 88 M
Jack Jones 33 M
Sally Jones 44 F

...and jack logged into the system, I have a page set up where I would like his record to be pulled up and be displayed to him without getting any information about bob or sally. I hope this makes it better

Let's say that jack logged into the system. You can save the name jack into a $_SESSION variable (i.e. $_SESSION = jack) when you make the database call for his information use

SELECT * FROM User WHERE FirstName = $_SESSION['fname']

That will return all the information related to jack.

Let's say that jack logged into the system. You can save the name jack into a $_SESSION variable (i.e. $_SESSION = jack) when you make the database call for his information use

SELECT * FROM User WHERE FirstName = $_SESSION['fname']

That will return all the information related to jack.

Thank you again...it makes sense. Can you give me some clues as to saving a session variable....Im very very new to PHP and I am just trying to learn...Thank you again

In order to start saving session variables you will need to start a session.

<? session_cache_limiter('private, must-revalidate');
    session_start(); ?>

after which it will be the same as declaring any other variable(i.e. $_SESSION = whatever;

Thank you very much, it worked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.