0

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.

3
Contributors
7
Replies
10
Views
7 Years
Discussion Span
Last Post by GTRMcLaren
1

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.

1

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

0

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

0

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.

0

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

0

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;

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.