无法从登录页面传递并显示用户名到主页

时间:2017-04-27 18:17:28

标签: php session variables webpage

我试图通过登录页面将登录用户名传递到仪表板,以便通过SQL查询显示名字和姓氏。我的用户名变量是空的,我无法弄清楚原因。任何帮助都会很精彩。

Login-submit.php页面!

if ($count){
  $_SESSION['username'] = $username;// $_SESSION['loggedin'] = true or false would work too
  $_SESSION['password'] = $password; // Why store the password in session data?
  $user= $_SESSION['username']

  header("Location: pageMLC_Dashboard.php");
    exit();
}else{
  $message="InvalidLogin";
  header("Location: pageMLC.php?message");
    exit();
}

if ($count){ $_SESSION['username'] = $username;// $_SESSION['loggedin'] = true or false would work too $_SESSION['password'] = $password; // Why store the password in session data? $user= $_SESSION['username'] header("Location: pageMLC_Dashboard.php"); exit(); }else{ $message="InvalidLogin"; header("Location: pageMLC.php?message"); exit(); } 信息中心页面

1 个答案:

答案 0 :(得分:0)

请记住在每个页面的顶部运行session_start()函数(可能包含在每个页面开头调用的php文件中?)。此函数创建或恢复当前会话。