How can I get the user information when the user successfully login?
Here is my login.php code
You already have username and password coming from the POST array, you can store them in session like this:
session_start(); // this will go on top of the page
.........
if($count == 1) {
session_register(username);
session_register(password);
$_SESSION['username'] = $_POST['username']; // store username
$_SESSION['password'] = $_POST['password']; // store password
header('location: index.php');
}
else {
$error = "Invalid Username or Password Please Try Again";
}
Later you can get them like:
echo $_SESSION['username'];
echo $_SESSION['password'];
Note that you should destroy them in session logout file.
Note 2 session_register has been DEPRECATED as of PHP 5.3.0. Simply use $_SESSION array for storing your values.