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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

regester session variables

Status
Not open for further replies.

schoch

Technical User
Jan 17, 2007
13
0
0
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.
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
Code:
<?php echo $_SESSION['MM_Password']; ?>
 
you are using dreamweaver. and an old version at that. you really must not. this is the third question you have asked in this forum that leads from a use of Dreamweaver occluding the real functionality of php from you.

you are also using addslashes() for database escaping rather than mysql_escape_string or mysql_real_escape_string.

this usage
Code:
session_register("MM_Username");
is deprecated (and has been deprecated for quite some time). read the manual on this.

the reason, I would hazard, that your variables are not showing up in the reserved pages is because you have not assigned any value to the variable. instead of the code above I would use
Code:
$_SESSION['MM_Username"] = $GLOBALS['MM_Username'];

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top