Going from database to sessions

后端 未结 2 938
执念已碎
执念已碎 2021-01-29 15:17

Well I have my register done all nice, as required fields it holds your email, name, and password. When you log in it asks for your email and password.

When they log in

相关标签:
2条回答
  • 2021-01-29 15:54

    When the user logins in with their username/password and after verification of the information, query the database for their record. Set the returned value(s) into the session. If you are already getting information about the account, add a table join (if in separate tables) or the columns.

    0 讨论(0)
  • 2021-01-29 15:55

    When they log in and you are checking the login credentials (email and password), if you find the user, select their first name as well and store it in another session variable:

    $query = 'SELECT firstname FROM users WHERE email = $email AND password = $password LIMIT 1';
    ...
    if ($result && mysql_num_rows($result) == 1) {
        $row = mysql_fetch_object($result);
        $_SESSION['firstname'] = $row->firstname;
        ...
    

    That might not be exact based on table and column names, but that's the general idea.

    0 讨论(0)
提交回复
热议问题