2017-04-19 134 views
-1

我看到相關的主題,但想知道是否有人可以請幫助我。這裏是錯誤持續存在的代碼的開始。我只是維護我的組織的網站,並沒有編寫任何代碼。希望有人可以請幫助建議修復以下代碼片段:致命錯誤:調用未定義的函數session_register()

session_name('melroseSoccerAdmin'); 
session_start(); 
session_register('current_user_id'); 
session_register('current_user_firstName'); 
session_register('current_user_lasstName'); 
session_register('current_user_username'); 
session_register('current_user_isAdmin'); 
session_register('current_user_team_id'); 
session_register('perpetuate'); 

/* If session not yet validated or session time expired, check credentials */ 
if (!$_SESSION['perpetuate'] || $_SESSION['perpetuate'] < time()) { 
    $dbh = mysql_connect($leagueHost, $leagueUser, $leaguePass) or die ('cannot connect'); 
    $authSQL = "SELECT users.user_firstName, users.user_lastName, users.user_isAdmin, users.user_id, users.team_id, leagues.league_id "; 
    $authSQL .= "FROM users "; 
    $authSQL .= "LEFT JOIN teams ON users.team_id = teams.team_id "; 
    $authSQL .= "LEFT JOIN leagues ON teams.league_id = leagues.league_id "; 
    $authSQL .= "WHERE user_username = '" . addslashes($username) . "' AND user_password = PASSWORD('" . addslashes($password) . "')"; 
    $result = mysql_db_query($leagueDB, $authSQL, $dbh) or die ('bad login query'); 
    header("HTTP/1.0 401 Unauthorized"); 

while (list($firstName, $lastName, $isAdmin, $id, $team_id, $league_id) = mysql_fetch_row($result)) { 
    $perpetuate = time() + $sessionLength; 
    $_SESSION['perpetuate'] = $perpetuate; 
    $current_user_id = $id; 
    $_SESSION['current_user_id'] = $current_user_id; 
    $current_user_name = $username; 
    $_SESSION['current_user_username'] = $current_user_username; 
    $current_user_firstName = $firstName; 
    $_SESSION['current_user_firstName'] = $current_user_firstName; 
    $current_user_lastName = $lastName; 
    $_SESSION['current_user_lastName'] = $current_user_lastName; 
    $current_user_isAdmin = $isAdmin; 
    $_SESSION['current_user_isAdmin'] = $current_user_isAdmin; 
    $current_user_team_id = $team_id; 
    $_SESSION['current_user_team_id'] = $current_user_team_id; 
+0

你能(或點我的人誰可以)與代碼幫助嗎?我不是Web開發人員,也不確定在這裏需要更新什麼語法。如果有幫助,我可以發送完整的checklogin.php。 – user7886937

回答

1

您不需要使用註冊功能。您可以使用會話變量是這樣的:

$_SESSION['current_user_team_id'] = 'something'; 

This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

http://php.net/manual/en/function.session-register.php

+0

謝謝你的回覆。 I'msorry - 我不熟悉代碼。 你是否知道我是否可以簡單地將上述(以前包含的session_register)事件替換爲以下內容:$ _SESSION('current_user_id'); $ _SESSION('current_user_firstName'); $ _SESSION('current_user_lasstName'); $ _SESSION('current_user_username'); $ _SESSION('current_user_isAdmin'); $ _SESSION('current_user_team_id'); $ _SESSION('perpetuate'); – user7886937

相關問題