douzhigan1687 2017-04-29 22:32 采纳率: 0%
浏览 42

PHP会话的用户ID

How can I save the user Id when is filling a form using PHP (Sessions)?? I mean how do get this session and I write the SQL query to save the uder ID in the form that has been submitted...

This is my session

session_start();
$_SESSION['user_id'] = $data['user_id'];
$_SESSION['first_name'] = $data['first_name'];

and here when the user log in to fill the form

session_start();
if (!isset($_SESSION['agent']) OR ($_SESSION['agent'] != md5($_SERVER['HTTP_USER_AGENT']) )) {
    // Need the functions:
    require ('includes/login_functions.inc.php');
    redirect_user();
    // Print a message:
}
echo "<span>You are now logged in, {$_SESSION['first_name']}!<a href=\"logout.php\">Logout</a></p></span>";
  • 写回答

0条回答 默认 最新

    报告相同问题?