使用相同的用户名链接两个表

时间:2012-08-13 12:12:06

标签: php mysql forms

我有两张桌子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'];
 }

0 个答案:

没有答案