Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying session variable

Status
Not open for further replies.

schoch

Technical User
Jan 17, 2007
13
AU

I can view the username, but the password cannot be displayed on the page.
This is a login form and I want to be able to display the password on one of the interior restricted pages. however it doesn't seem to be registering the variable. The username can be displayed but not the password, why?
Code:
<?php
// *** Validate request to login to this site.
session_start();

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($accesscheck)) {
  $GLOBALS['PrevUrl'] = $accesscheck;
  session_register('PrevUrl');
}

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "usergroup";
  $MM_redirectLoginSuccess = "admin_menu.php";
  $MM_redirectLoginFailed = "login.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_voip, $voip);
      
  $LoginRS__query=sprintf("SELECT franchisee_name, franchisee_code, usergroup FROM franchisee WHERE franchisee_name='%s' AND franchisee_code='%s'",
  get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $voip) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
    
    $loginStrGroup  = mysql_result($LoginRS,0,'usergroup');
    
    $GLOBALS['MM_Username'] = $loginUsername;
        $GLOBALS['MM_Password'] = $password;
   $GLOBALS['MM_UserGroup'] = $loginStrGroup;          

    //register the session variables
    session_register("MM_Username");
        session_register("MM_Password");
   session_register("MM_UserGroup");

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];    
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
Then when I go to display the session variable I use

<?php echo $_SESSION['MM_Password']; ?>
 
For help on PHP problems please post in forum434

To find out how the forum works, anf how to get the best from it, read faq222-2244

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
depends how your password is stored...you may need to unhash it.also I would suggest that you do not drag passwords in sessions but rather pull them from the table as needed based on the fact that user has authenticated.
All the best!

:--------------------------------------:
fugitive.gif


All around in my home town,
They tryin' to track me down...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top