0

我有两张表 USERS 和 CASH_FLOW_PLAN

我想从当前登录用户的 USERS 表中继承用户名,并将其用作 CASH_FLOW_PLAN 表的主键,这样就可以打印来自 CASH_FLOW_PLAN 的信息,将其带到新页面......等等...因此,例如,我已经登录并被重定向到一个名为 cash-flow-plan.php 的页面,然后我在其中输入一堆工资信息和数字,这些信息和数字与当前登录的用户一起存储在 CASH_FLOW_PLAN 表中用户名。

我有一个会话延续到每一页

function startSession(){
  global $database;  //The database connection
  session_start();   //Tell PHP to start the session

  /* Determine if user is logged in */
  $this->logged_in = $this->checkLogin();

  /**
   * Set guest value to users not logged in, and update
   * active guests table accordingly.
   */
  if(!$this->logged_in){
     $this->username = $_SESSION['username'] = GUEST_NAME;
     $this->userlevel = GUEST_LEVEL;
     $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time);
  }
  /* Update users last active timestamp */
  else{
     $database->addActiveUser($this->username, $this->time);
  }

  /* Remove inactive visitors from database */
  $database->removeInactiveUsers();
  $database->removeInactiveGuests();   

  /* Set current url */
  $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF'];
 }
4

0 回答 0