doubiaokai4998 2011-08-09 18:35
浏览 32
已采纳

从基于会话数据的表中获取值

I have an admin section to one of my websites I am building.

The variables it logs in by is email address and password.

Obviously each email address is unique to each admin, although I do have an 'admin_id' column which increments automatically per row.

The other columns stored within my admin table are - First Name (String), Last Name(String), Level(int).

I have tried -

$_SESSION['admin_id']=$_GET['admin_id'];

But when I try and simply echo the id, nothing is displayed.

Yet this line of code:

if(!isset($_SESSION['admin_email'])) 
die("<meta http-equiv='refresh' content='0; url=login.php'> ");

Manages to get the 'Admin_email' column from the table.

I am confused as to how to add other columns into my session data.

Many thanks in advance.

  • 写回答

1条回答 默认 最新

  • dongxian6741 2011-09-24 20:59
    关注

    I have figured out why the 'admin_id' was not successful in been retrieved from the database.

    The login.php where the admin first must authenticate themselves from is where the session data is saved - for it to be used in the admin session once logged in.

    In order to solve this, I added the following line within the login.php (whilst the email address were been retrieved from the database):

    $dblevel = $row['level']; 
    

    and then to save it to a session:

    $_SESSION['admin_level']=$dblevel; 
    

    I logged out and then back in to reinitiate the session and it worked.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 nrf52810-c三个a 程序
  • ¥15 lego-loam跑出来的roll误差很大
  • ¥50 求一个半透明没有锯齿的圆角窗体的实现例子
  • ¥15 STM32cubeMX里的FreeRTOS无法释放内存
  • ¥15 CATIA有些零件打开直接单机确定终止
  • ¥15 请问有会的吗,用MATLAB做
  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对