I cant seem to get any of my users other information pulled from the database other than their username and ID and im not understanding why, heres my code trying to call it from session.

// Now we check if the data was submitted, isset will check if the data exists.
if ( !isset($_POST['username'], $_POST['password']) ) {
    // Could not get the data that should have been sent.
    die ('Username and/or password does not exist!');
// Prepare our SQL
if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {
    // Bind parameters (s = string, i = int, b = blob, etc), hash the password using the PHP password_hash function.
    $stmt->bind_param('s', $_POST['username']);
    // Store the result so we can check if the account exists in the database.
    if ($stmt->num_rows > 0) {
        $stmt->bind_result($id, $password);
        // Account exists, now we verify the password.
        if (password_verify($_POST['password'], $password)) {
            // Verification success! User has loggedin!
            $_SESSION['loggedin'] = TRUE;
            $_SESSION['username'] = $_POST['username'];
            $_SESSION['id'] = $id;
            $_SESSION['title'] = $title;
            $_SESSION['website'] = $website;
            $_SESSION['youtube'] = $youtube;
            $_SESSION['facebook'] = $facebook;
            $_SESSION['paypalemail'] = $paypalemail;
            echo 'Welcome ' . $_SESSION['username'] . '!';
                echo 'Welcome ' . $_SESSION['title'] . '!';
      echo'<a href="/profile.php">My Profile </a>';
        } else {
            echo 'Incorrect username and/or password!';
    } else {
        echo 'Incorrect username and/or password!';
} else {
    echo 'Could not prepare statement!';

closed as off-topic by Tetsujin, fixer1234, Toto, music2myear, bertieb Jan 30 at 19:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question is not about computer hardware or software, within the scope defined in the help center." – Tetsujin, fixer1234, music2myear, bertieb
If this question can be reworded to fit the rules in the help center, please edit the question.


Where are the variables $title,$website,$youtube,$facebook,$paypalemail coming from? If they are stored in the accounts table with the same column names as the variable names you used you need to retrieve them along with the id and password.


if ($stmt = $con->prepare('SELECT id, password FROM accounts WHERE username = ?')) {


if ($stmt = $con->prepare('SELECT 
FROM accounts WHERE username = ?')) {
  • Thank you! Yes they are in the databse and I attempted to add them their to no prevail but this looks exactly what I was wanting thank you sir! – Sebastian Shearer Jan 29 at 22:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.