I have a database and a table within called 'data'..
I also have a login script that allows users to access it. My question is..how do I make only the user's record viewable/accessible after login. Specifically, how do I access, the a specific record in the database using php code??? ... Some of my variables are $email, $phone, $address.....etc..
I want to display only the users data when they login and I want then to be able to update it...
Your coding example is correct as long as the variable $memberid holds the correct ID number for the current user/member.
In my example the userID is the column name in the database, the $user is a php variable that holds the user/memeber's id.
I am not sure where you are holding the user information once the user has signed in, but in order to have access to this information on every page and eve subsequent requests to the same page you will have to put this information into session or cookie variables. Session variables might make the most sense.
session_start(); // required for session variables
$_SESSION['memberid'] = $memberid; // Perform after user has successfully logged in
$memberid = $_SESSION['memberid'] // Perform whenever you need access to Member ID
The session_start function is required to set up a session and access session variables.
The first statement goes into your login script, after the user has provided a good password. You only need this once and you can use unset($_SESSION), to remove the session variables when the user logs off.
The second statement is used whenever you need to perform any tests based on the memberid. You can access the $_SESSION variable directly, but if you are going to use it more than once it is best to create a local variable.