MM_Username Variable

Hi. I hope someone can help as I've been struggling with this
for a few weeks.
On the first php page I have the user register and log in
automatically. On the 2nd php page i want to greet the username but
the MM_Username variable won't appear on the screen. I'm using
Apache2 as the testing server. Where am I going wrong?
Here's the code:-

<?php require_once('Connections/registration.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType,
$theDefinedValue = "", $theNotDefinedValue = "")
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue)
: $theValue;
$theValue = function_exists("mysql_real_escape_string") ?
mysql_real_escape_string($theValue) :
mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" :
"NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) .
"'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" :
"NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue :
$theNotDefinedValue;
break;
return $theValue;
// *** Redirect if username exists
$MM_flag="MM_insert";
if (isset($_POST[$MM_flag])) {
$MM_dupKeyRedirect="usernam.html";
$loginUsername = $_POST['username'];
$LoginRS__query = sprintf("SELECT username FROM tablename1
WHERE username=%s", GetSQLValueString($loginUsername, "text"));
mysql_select_db($database_registration, $registration);
$LoginRS=mysql_query($LoginRS__query, $registration) or
die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
//if there is a row in the database, the username was found
- can not add the requested username
if($loginFoundUser){
$MM_qsChar = "?";
//append the username to the redirect page
if (substr_count($MM_dupKeyRedirect,"?") >=1) $MM_qsChar
= "&";
$MM_dupKeyRedirect = $MM_dupKeyRedirect . $MM_qsChar
."requsername=".$loginUsername;
header ("Location: $MM_dupKeyRedirect");
exit;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" .
htmlentities($_SERVER['QUERY_STRING']);
if ((isset($_POST["MM_insert"])) &&
($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tablename1 (fname,
surname, sex, country, email, username) VALUES (%s, %s, %s, %s, %s,
%s)",
GetSQLValueString($_POST['fname'], "text"),
GetSQLValueString($_POST['surname'], "text"),
GetSQLValueString(isset($_POST['sex']) ? "true" : "",
"defined","1","0"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['username'], "text"));
mysql_select_db($database_registration, $registration);
$Result1 = mysql_query($insertSQL, $registration) or
die(mysql_error());
$insertGoTo = "recordin.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
header(sprintf("Location: %s", $insertGoTo));
?><?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
session_start();
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
$_SESSION['PrevUrl'] = $_GET['accesscheck'];
if (isset($_POST['username'])) {
$loginUsername=$_POST['username'];
$password=$_POST['email'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "recordin.php";
$MM_redirectLoginFailed = "usernam.html";
$MM_redirecttoReferrer = false;
mysql_select_db($database_registration, $registration);
$LoginRS__query=sprintf("SELECT username, email FROM
tablename1 WHERE username=%s AND email=%s",
GetSQLValueString($loginUsername, "text"),
GetSQLValueString($password, "text"));
$LoginRS = mysql_query($LoginRS__query, $registration) or
die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
if (isset($_SESSION['PrevUrl']) && false) {
$MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
header("Location: " . $MM_redirectLoginSuccess );
else {
header("Location: ". $MM_redirectLoginFailed );
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for
(i=0;!x&&i<d.forms.length;i++) x=d.forms
[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n);
return x;
function MM_validateForm() { //v4.0
var
i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2];
val=MM_findObj(args
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must
contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain
a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is
required.\n'; }
} if (errors) alert('The following error(s)
occurred:\n'+errors);
document.MM_returnValue = (errors == '');
//-->
</script>
</head>
<body>
<div align="center">
<form action="<?php echo $loginFormAction; ?>"
method="POST" name="form1" id="form1"
onsubmit="MM_validateForm('fname','','R','surname','','R','email','','RisEmail','username ','','R');return
document.MM_returnValue">
<table width="500" border="0">
<tr>
<td><label>First name
<input name="fname" type="text" id="fname" />
</label></td>
<td><label>Surname
<input name="surname" type="text" id="surname" />
</label></td>
</tr>
<tr>
<td>Sex:
<label> M
<input name="sex" type="radio" value="radiobutton" />
F
<input name="radiobutton" type="radio"
value="radiobutton" />
</label></td>
<td><label>Country
<select name="country" size="1" id="country">
<option>Austrailia</option>
<option>Japan</option>
<option>United Kingdom</option>
<option>United States</option>
</select>
</label></td>
</tr>
<tr>
<td><label>Email address
<input name="email" type="text" id="email" />
</label></td>
<td><label>Username
<input name="username" type="text" id="username" />
</label></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</div></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
</div>
</body>
</html>

Similar Messages

  • Problem with PHP Session Variables

    Hello all,
    I am in the process of converting an internal company site
    from ASP/Access to PHP/MySQL. All was going well until I started
    working with User Authentication involving access level. No matter
    what I do I can't seem to shake the MM_UserGroup variable.
    I have a link on the main page that is variable dependent on
    the access level of the user. If the user is logged in as a
    Supervisor they should see a link to the supervisor control panel.
    If logged in as a user or not logged in at all, they should see a
    link to the supervisor login page.
    I have put a Restrict Access function on the supervisor
    control panel and it functions as usual. When logged in as a
    supervisor I have access. When logged in as a user or not logged in
    at all, I don't.
    It seems that my homepage always sees the MM_UserGroup
    variable set as "Supervisor". I can log in as a user, close the
    browser, restart the server, everything and it always sees the
    variable set as "Supervisor". Just to make sure I wasn't crazy I
    put in an echo function so that it would display "MM_UserGroup". It
    always says "Supervisor" no matter what I do. Using echo to show
    the MM_Username variable, it functions as expected. When I close
    the browser and reopen it, I get a nice error as expected because
    there is no one logged in at that time. I still see "Supervisor"
    staring me in the face though.
    I'm sure it's something simple that I'm missing, not being an
    experienced PHP user.
    Any thoughts from the experts out there?
    Thanks in advance,
    David

    aidan81 wrote:
    > immediately upon login for a user, I see "User" printed
    as expected. Once I
    > use this page to edit their status, I am redirected back
    to the main page as
    > expected and immediately see "Supervisor" staring at me.
    If I then revisit the
    > user's edit page, it now says "Supervisor". Seems that
    something screwy is
    > going on and I'm at a loss....
    It sounds as though you are reassigning the value of the
    variable. If my
    memory serves me right, ASP uses a single equal sign to
    perform a
    comparison. PHP uses two.
    Check that you don't have something like this in your code:
    if ($_SESSION['Authority'] = 'Supervisor') {
    // do something
    That will assign Supervisor to $_SESSION['Authority'].
    It should be this:
    if ($_SESSION['Authority'] == 'Supervisor') {
    // do something
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Displaying username after login [was: Am I missing something?]

    I am trying to have users log in and then display and use their login name, etc on the next page. I have read the posts on how the add the login server behaviour to the login page, and I did this.
    The problem is that after logging in, the user is directed to the right page (loginsuccess), but it seems that the MM_Username variable is not set, because I cannot get it to display on the page.
    Please help.
    Here is the login page:
    http://www.dataworkstt.com/login.php
    and the success page is
    http://www.dataworkstt.com/loginsuccess.php
    Dexter
    [Subject line modified by moderator to indicate nature of question]

    Hi, This is a lot, but this is the login.php page
    <!--
    function MM_validateForm() { //v4.0
       if (document.getElementById){
         var 
    i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
         for (i=0; i<(args.length-2); i=3) { test=args[i2]; 
    val=document.getElementById(args+);
           if (val) { nm=val.name; if ((val=val.value)!="") {
             if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
               if (p<1 || p==(val.length-1)) errors='- 'nm+' must 
    contain an e-mail address.\n';
             } else if (test!='R') { num = parseFloat(val);
               if (isNaN(val)) errors='- 'nm+' must contain a number.\n';
               if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
                 min=test.substring(8,p); max=test.substring(p+1);
                 if (num<min || max<num) errors='- 'nm+' must contain a 
    number between 'min' and 'max'.\n';
           } } } else if (test.charAt(0) == 'R') errors = '- 'nm+' is 
    required.\n'; }
         } if (errors) alert('The following error(s) occurred:\n'+errors);
         document.MM_returnValue = (errors == '');
    //-->
    <!--
    body, td, th
    .style1
    .style2 {font-size: 14px}
    .style4
    -->
    DATAWORKS Trinidad and Tobago
    | HOME | ABOUT | CONTACT |
                 <!-- Change these links and press F12 to test ><! 
    #BeginLibraryItem "/Templates/navigation.lbi" -->
    Desktop Publishing
    Corporate Identity
    Logo Design
    Letterheads
    Business Cards
    Office Documents
    Forms Design
    Invoices/Bill Books
    Photo Copying
    Quick Printing
    Binding & Finishing
    Collaterals
    Brochures
    Flyers/Posters
    Certificates
    Advertisements
    Publications
    Report Books
    Membership Booklets
    Technical Manuals
    Annual Reports
    Plastic Cards
    Photo ID Cards
    School ID Cards
    Employee ID Badges
    Membership Badges
    Conference Badges
    Loyalty Cards
    VIP Cards
    Discount Cards
    Rewards Cards
    Speciality Cards
    Key Cards
    Plastic Card Tickets
    Plastic Business Cards
    FaceBook Cards
    Fundraising Cards
    Gift Cards
    Prayer Cards
    Celebrity Cards
    Calendar Cards
    Web Development
    Web Design & Maintenance
    Flash Animation/Scripting
    Data Modelling
    School Databases
    Membership Databases
    Business Databases
                                 <param name="FlashVars" 
    value="flashlet=" />
    Desktop Publishing
    Corporate Identity
    Office Documents
    Collaterals</  a>
    Publications
    Plastic Cards
    Photo ID Cards</  a>
    Membership Cards
    Speciality Cards
    Web Development
    Web Design</  a>
    Web Maintenance
    Scripting & Animation
    Data Modelling
    School Databases
    Membership Databases
    Business Databases
    Member Login</  td>
    Email Address
    Password
    </  div>
    | Desktop Publishing | Plastic Cards | Web Development | Data Modelling | Home | About | Contact | Services Map |
    112 Second Street, Barataria, Trinidad and Tobago, W.I.
    Phone: (868) 675-2220 E-mail address: [email protected]
    Copyright © 2008 DataWorkstt.com,
    All Rights Reserved
    </html

  • Issue with setting mm_username

    Folks,
    I'm new to DreamWeaver, and to web design in general, so I'm fairly sure I'm doing something obvious wrong. I have an SQL database with registered users in, I have a php login page, and I have a php "welcome" page, on which, I want to display the name of the user who's logged in.
    I'm able to log in fine, I have a restricted page for the "welcome", and I have my datasource set to filter on the session variable of mm_username. However, when the page opens, there's nothing returned. if I don't set the datasource to filter, then, data is returned.
    Here's the code for my login page:
    <?php session_start(); ?>
    <?php require_once('../../Connections/SpartansUsers.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    ?>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      session_start();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    if (isset($_POST['name'])) {
      $loginUsername=$_POST['name'];
      $password=$_POST['password'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "Welcome.php";
      $MM_redirectLoginFailed = "userLogin.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_SpartansUsers, $SpartansUsers);
      $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $SpartansUsers) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        //declare two session variables and assign them
        $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;         
        if (isset($_SESSION['PrevUrl']) && false) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];   
        header("Location: " . $MM_redirectLoginSuccess );
      else {
        header("Location: ". $MM_redirectLoginFailed );
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    body {
        font: 100% Verdana, Arial, Helvetica, sans-serif;
        background: #666666;
        margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
        padding: 0;
        text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
        color: #000000;
    .oneColElsCtr #container {
        width: 46em;
        background: #FFFFFF;
        margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
        border: 1px solid #000000;
        text-align: left; /* this overrides the text-align: center on the body element. */
    .oneColElsCtr #mainContent {
        padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
    -->
    </style></head>
    <body class="oneColElsCtr">
    <div id="container">
      <div id="mainContent">
            <form id="userLogin" name="userLogin" method="POST" action="<?php echo $loginFormAction; ?>">
              <table width="650" border="0">
                  <tr>
                     <td width="120">User Name</td>
                     <td width="520"><input name="name" type="text" id="name" size="75" /></td>
                  </tr>
                  <tr>
                     <td>Password</td>
                    <td><input name="password" type="password" id="password" size="75" /></td>
                  </tr>
                 <tr>
                    <td></td>
                    <td><input name="login" type="submit" value="Log In" /></td>
                  </tr>
            </table>
        </form>
        <!-- end #mainContent --></div>
    <!-- end #container --></div>
    </body>
    </html>
    And here's the code for my "welcome" page:
    <?php session_start(); ?>
    <?php require_once('../../Connections/SpartansUsers.php'); ?>
    <?php
    if (!isset($_SESSION)) {
      session_start();
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";
    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
      // For security, start by assuming the visitor is NOT authorized.
      $isValid = False;
      // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
      // Therefore, we know that a user is NOT logged in if that Session variable is blank.
      if (!empty($UserName)) {
        // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
        // Parse the strings into arrays.
        $arrUsers = Explode(",", $strUsers);
        $arrGroups = Explode(",", $strGroups);
        if (in_array($UserName, $arrUsers)) {
          $isValid = true;
        // Or, you may restrict access to only certain users based on their username.
        if (in_array($UserGroup, $arrGroups)) {
          $isValid = true;
        if (($strUsers == "") && true) {
          $isValid = true;
      return $isValid;
    $MM_restrictGoTo = "userLogin.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
      $MM_referrer .= "?" . $QUERY_STRING;
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
      header("Location: ". $MM_restrictGoTo);
      exit;
    ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $colname_uDetails = "-1";
    if (isset($_SESSION['MM_username'])) {
      $colname_uDetails = $_SESSION['MM_username'];
    mysql_select_db($database_SpartansUsers, $SpartansUsers);
    $query_uDetails = sprintf("SELECT firstname, surname FROM users WHERE username = %s", GetSQLValueString($colname_uDetails, "text"));
    $uDetails = mysql_query($query_uDetails, $SpartansUsers) or die(mysql_error());
    $row_uDetails = mysql_fetch_assoc($uDetails);
    $totalRows_uDetails = mysql_num_rows($uDetails);
    ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    <!--
    body {
        font: 100% Verdana, Arial, Helvetica, sans-serif;
        background: #666666;
        margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */
        padding: 0;
        text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */
        color: #000000;
    .oneColElsCtr #container {
        width: 46em;
        background: #FFFFFF;
        margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */
        border: 1px solid #000000;
        text-align: left; /* this overrides the text-align: center on the body element. */
    .oneColElsCtr #mainContent {
        padding: 0 20px; /* remember that padding is the space inside the div box and margin is the space outside the div box */
    -->
    </style></head>
    <body class="oneColElsCtr">
    <div id="container">
      <div id="mainContent">
        <?php echo 'Welcome, ' . $row_uDetails['firstname'] . ' ' . $row_uDetails['surname']; ?>
        <p>MM_username <?php echo $_SESSION['MM_username']; ?> should be here</p>
      <!-- end #mainContent --></div>
    <!-- end #container --></div>
    </body>
    </html>
    <?php
    mysql_free_result($uDetails);
    ?>
    If someone can tell me what it is I've done wrong, I'd really appreciate it, as it's driving me crazy!!

    In your 'welcome.php' page you have 3 instances of a lower case 'u' - 'MM_username' when they should be MM_Username.
    2 here:
    $colname_uDetails = "-1";
    if (isset($_SESSION['MM_username'])) {
      $colname_uDetails = $_SESSION['MM_username'];
    1 here:
    <p>MM_username <?php echo $_SESSION['MM_username']; ?> should be here</p>

  • Filtering a Recordset with session variable

    Hi
    I am trying to filter a recordset based on a session
    variable. The session variable is passed from the login page via a
    username which is their email address. This has been successful.
    However when I want to filter the users table - tbl_users to
    show their first name it doesn't work.
    I followed the adobe help tutorial plus ahave tried other
    combinations and I am now at a loss on where exactly I am going
    wrong.
    The recordset is rs_UserAccess
    I have a session variable called - MM_Username
    The table has 5 records of various users
    The code that I have fiddling with is -
    <%
    Dim rs_UserAccess
    Dim rs_UserAccess_numRows
    Set rs_UserAccess = Server.CreateObject("ADODB.Recordset")
    rs_UserAccess.ActiveConnection = MM_conn_sidecounter_STRING
    rs_UserAccess.Source = "SELECT * FROM tbl_users WHERE
    username = MM_Username"
    rs_UserAccess.CursorType = 0
    rs_UserAccess.CursorLocation = 2
    rs_UserAccess.LockType = 1
    rs_UserAccess.Open()
    rs_UserAccess_numRows = 0
    %>
    Any help would be appreciated. I have outlined below the
    different combinations I have tested.
    Try No1
    rs_UserAccess.Source ="SELECT * FROM tbl_users WHERE username
    = Session("MM_Username")”
    Message:
    Microsoft VBScript compilation error '800a0401'
    Expected end of statement
    /main.asp, line 182
    Try No2
    rs_UserAccess.Source ="SELECT * FROM tbl_users WHERE username
    = Session(‘MM_Username’)”
    Message:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    [Microsoft][ODBC Microsoft Access Driver] Undefined function
    'Session' in expression.
    /main.asp, line 186
    Try No3
    rs_UserAccess.Source ="SELECT * FROM tbl_users WHERE username
    = Session(MM_Username)”
    Message:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    [Microsoft][ODBC Microsoft Access Driver] Undefined function
    'Session' in expression.
    /main.asp, line 186
    Try No4
    rs_UserAccess.Source ="SELECT * FROM tbl_users WHERE username
    = Session Variable MM_Username"
    Message:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
    [Microsoft][ODBC Microsoft Access Driver] Syntax error
    (missing operator) in query expression 'username = Session Variable
    MM_Username'.
    /main.asp, line 186
    Try No5
    rs_UserAccess.Source ="SELECT * FROM tbl_users WHERE username
    = MM_Username"
    Message:
    Microsoft OLE DB Provider for ODBC Drivers error '80040e10'
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters.
    Expected 1.
    /main.asp, line 186
    Thanks in advance
    Cheers
    Downsy

    Try this:
    rs_UserAccess.Source = "SELECT * FROM tbl_users WHERE
    username = " & Session("MM_Username")
    Keep that on one line.
    Ken Ford
    Adobe Community Expert
    Fordwebs, LLC
    http://www.fordwebs.com
    "Downsy42" <[email protected]> wrote in
    message news:[email protected]...
    > Hi
    > I am trying to filter a recordset based on a session
    variable. The session
    > variable is passed from the login page via a username
    which is their email
    > address. This has been successful.
    > However when I want to filter the users table -
    tbl_users to show their first
    > name it doesn't work.
    > I followed the adobe help tutorial plus ahave tried
    other combinations and I
    > am now at a loss on where exactly I am going wrong.
    > The recordset is rs_UserAccess
    > I have a session variable called - MM_Username
    > The table has 5 records of various users
    >
    > The code that I have fiddling with is -
    >
    > <%
    > Dim rs_UserAccess
    > Dim rs_UserAccess_numRows
    >
    > Set rs_UserAccess =
    Server.CreateObject("ADODB.Recordset")
    > rs_UserAccess.ActiveConnection =
    MM_conn_sidecounter_STRING
    > rs_UserAccess.Source = "SELECT * FROM tbl_users WHERE
    username = MM_Username"
    > rs_UserAccess.CursorType = 0
    > rs_UserAccess.CursorLocation = 2
    > rs_UserAccess.LockType = 1
    > rs_UserAccess.Open()
    >
    > rs_UserAccess_numRows = 0
    > %>
    >
    >
    >
    > Any help would be appreciated. I have outlined below the
    different
    > combinations I have tested.
    >
    >
    > Try No1
    > rs_UserAccess.Source ="SELECT * FROM tbl_users WHERE
    username =
    > Session("MM_Username")?
    > Message:
    > Microsoft VBScript compilation error '800a0401'
    > Expected end of statement
    > /main.asp, line 182
    >
    > Try No2
    > rs_UserAccess.Source ="SELECT * FROM tbl_users WHERE
    username =
    > Session(?MM_Username?)?
    > Message:
    > Microsoft OLE DB Provider for ODBC Drivers error
    '80040e14'
    > [Microsoft][ODBC Microsoft Access Driver] Undefined
    function 'Session' in
    > expression.
    > /main.asp, line 186
    >
    > Try No3
    > rs_UserAccess.Source ="SELECT * FROM tbl_users WHERE
    username =
    > Session(MM_Username)?
    > Message:
    > Microsoft OLE DB Provider for ODBC Drivers error
    '80040e14'
    > [Microsoft][ODBC Microsoft Access Driver] Undefined
    function 'Session' in
    > expression.
    > /main.asp, line 186
    >
    > Try No4
    > rs_UserAccess.Source ="SELECT * FROM tbl_users WHERE
    username = Session
    > Variable MM_Username"
    > Message:
    > Microsoft OLE DB Provider for ODBC Drivers error
    '80040e14'
    > [Microsoft][ODBC Microsoft Access Driver] Syntax error
    (missing operator) in
    > query expression 'username = Session Variable
    MM_Username'.
    > /main.asp, line 186
    >
    > Try No5
    > rs_UserAccess.Source ="SELECT * FROM tbl_users WHERE
    username = MM_Username"
    > Message:
    > Microsoft OLE DB Provider for ODBC Drivers error
    '80040e10'
    > [Microsoft][ODBC Microsoft Access Driver] Too few
    parameters. Expected 1.
    > /main.asp, line 186
    >
    > Thanks in advance
    > Cheers
    > Downsy
    >
    >
    >

  • Help with session variable please - CS5.5 PHP

    Hi all,
    I am needing a little assistance with using a session variable and hope that someone may point me in the right direction.
    I have created a PHP page that uses the Dreamweaver 'User Authentication' feature, and the basics of this works fine, directing a user to the correct pages depending on whether they are or are not a valid user. I would like however to personalise the 'valid user' page with the persons Username as entered in the User Authentication table....a seemingly simple task using a session variable, but one that I just don't seem to be able to get working!
    The code generated for the UA on page 1 is as follows:
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      session_start();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    if (isset($_POST['txtfirst_name'])) {
      $loginUsername=$_POST['txtfirst_name'];
      $password=$_POST['txtsurname'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "member_update.php";
      $MM_redirectLoginFailed = "login.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_panto, $panto);
      $LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND surname=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $panto) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
        //declare two session variables and assign them
       $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;         
        if (isset($_SESSION['PrevUrl']) && false) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];   
        header("Location: " . $MM_redirectLoginSuccess );
      else {
        header("Location: ". $MM_redirectLoginFailed );
    ?>
    Firstly, the text highlighted in red above appears to be setting the session variable that I require. Is This correct?
    If so, what is the code that I need to place in page 2 to use that session variable? or
    Do I need to do something else on page 1 to properly assign the session variable?
    Would really appreciate your expertise
    Mark

    It looks as though you've set the columns incorrectly in the User Authentication server behavior. This is the SQL query that checks the user's credentials:
      $LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND surname=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
    You're looking for firstname and surname, whereas you should be looking for the user's login name and password.
    $_SESSION['MM_Username'] is a session variable that stores the user's login name. To use it in a subsequent page, all that's needed is for the page to begin with session_start(). You can then echo the value to display it.
    If you want to display the person's real name, you need to create a recordset in the second page using $_SESSION['MM_Username'] to find the firstname and surname. Alternatively, you can edit the existing code like this (I've copied only part of it):
      $LoginRS__query=sprintf("SELECT firstname, surname FROM web_access WHERE firstname=%s AND password=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $panto) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        $row = mysql_fetch_assoc($LoginRS);
         $_SESSION['full_name'] = $row['firstname'] . ' ' . $row['surname'];
        if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
        //declare two session variables and assign them
       $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;
    You can then use $_SESSION['full_name'] in a subsequent page that begins with session_start().

  • Session variable not passing between pages

    Hi, I've got a form that calculates checkbox values and puts them in a total field called txtTotal. When the user clicks send, I need to pass the total to a payment page.  The form page has PHP
    session_start();
    $_SESSION['sessTotal'] = $_POST['txtTotal'];
    and the payment page has
    session_start(); at the top of the page and <?php echo $_SESSION['sessTotal']; ?> where I want the total to display. The total does not carry over to the payment page and I can't work out why.
    Here is all the PHP from the form page as I'm pretty new to PHP and not sure if there's a conflict (should session_start appear more than once?)  Thanks guys
    <?php require_once('Connections/df.php'); ?>
    <?php
    //initialize the session
    if (!isset($_SESSION)) {
    session_start();
    $_SESSION['sessTotal'] = $_POST['txtTotal'];
    // ** Logout the current user. **
    $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
    if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
      $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
    if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
      //to fully log out a visitor we need to clear the session varialbles
      $_SESSION['MM_Username'] = NULL;
      $_SESSION['MM_UserGroup'] = NULL;
      $_SESSION['PrevUrl'] = NULL;
      unset($_SESSION['MM_Username']);
      unset($_SESSION['MM_UserGroup']);
      unset($_SESSION['PrevUrl']);
      $logoutGoTo = "index.php";
      if ($logoutGoTo) {
        header("Location: $logoutGoTo");
        exit;
    ?>
    <?php
    if (!isset($_SESSION)) {
      session_start();
    $MM_authorizedUsers = "";
    $MM_donotCheckaccess = "true";
    // *** Restrict Access To Page: Grant or deny access to this page
    function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
      // For security, start by assuming the visitor is NOT authorized.
      $isValid = False;
      // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
      // Therefore, we know that a user is NOT logged in if that Session variable is blank.
      if (!empty($UserName)) {
        // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
        // Parse the strings into arrays.
        $arrUsers = Explode(",", $strUsers);
        $arrGroups = Explode(",", $strGroups);
        if (in_array($UserName, $arrUsers)) {
          $isValid = true;
        // Or, you may restrict access to only certain users based on their username.
        if (in_array($UserGroup, $arrGroups)) {
          $isValid = true;
        if (($strUsers == "") && true) {
          $isValid = true;
      return $isValid;
    $MM_restrictGoTo = "index.php";
    if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {  
      $MM_qsChar = "?";
      $MM_referrer = $_SERVER['PHP_SELF'];
      if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
      if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0)
      $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
      $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
      header("Location: ". $MM_restrictGoTo);
      exit;
    ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $colname_userDets = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_userDets = $_SESSION['MM_Username'];
    mysql_select_db($database_df, $df);
    $query_userDets = sprintf("SELECT usersId, userName, password, name FROM users WHERE userName = %s", GetSQLValueString($colname_userDets, "text"));
    $userDets = mysql_query($query_userDets, $df) or die(mysql_error());
    $row_userDets = mysql_fetch_assoc($userDets);
    $totalRows_userDets = mysql_num_rows($userDets);
    ?>

    OK I got it.  I needed 
    session_start();
    $_SESSION['sessTotal'] = $_POST['txtTotal'];
    on the payments page as well, not just session_start();

  • Login session variable - pls help before i slot myself

    im brand new to this guys and really struggling with logging
    in a member to their particular account as opposed to a general
    members section using dreamweavers login application and some basic
    php coding.
    i just cant seem to figure it out it (im stuck on the session
    variables i think..) and unfortunately my php is very poor at them
    moment!
    pls HELP!!
    below is the dreamweaver generated code from its basic login
    application.
    im using it in a dreamweaver template so im not sure if thats
    the issue but bascially im using 2 SQL tables i constructed to
    achieve this-
    1.) tblaccesslevel
    intLevelID (unsigned + auto increment + primary key)
    txtAccess
    (ive allocated various numerical access levels into
    txtAccess. ie. 1-7
    and
    2.) tblplayeraccount
    intUserID (unsigned + auto increment + primary key)
    txtFirstName
    txtLastName
    txtEmailAddress
    txtPassword
    intAccessLevel
    (ive generated 2 users in the above table tp test)
    in dreameavers server behaviors the recordset generated by
    the login server behavior simply says Log In User
    obviously i need a session variable somewhere to get the
    intUserId....
    also a relationship needs to be generated in the sql
    statement to connect the intAccessLevel but i think i can manage
    that (i think..)
    below is the code this application generated -
    if someone can give me some hints or if they've done
    something similiar pls provide the required code ...it would be a
    huge help!! i dont know what im doing wrong!!!
    <?php require_once('../Connections/Rugby.php'); ?>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
    session_start();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
    $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    if (isset($_POST['emailaddress'])) {
    $loginUsername=$_POST['emailaddress'];
    $password=$_POST['password'];
    $MM_fldUserAuthorization = "intAccessLevel";
    $MM_redirectLoginSuccess = "../player_home.php";
    $MM_redirectLoginFailed = "../failed.php";
    $MM_redirecttoReferrer = false;
    mysql_select_db($database_Rugby, $Rugby);
    $LoginRS__query=sprintf("SELECT txtEmailAddress, txtPassword,
    intAccessLevel FROM tblplayeraccount WHERE txtEmailAddress='%s' AND
    txtPassword='%s'",
    get_magic_quotes_gpc() ? $loginUsername :
    addslashes($loginUsername), get_magic_quotes_gpc() ? $password :
    addslashes($password));
    $LoginRS = mysql_query($LoginRS__query, $Rugby) or
    die(mysql_error());
    $loginFoundUser = mysql_num_rows($LoginRS);
    if ($loginFoundUser) {
    $loginStrGroup = mysql_result($LoginRS,0,'intAccessLevel');
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;
    if (isset($_SESSION['PrevUrl']) && false) {
    $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    header("Location: " . $MM_redirectLoginSuccess );
    else {
    header("Location: ". $MM_redirectLoginFailed );
    ?>

    Are you wanting to redirect them to a specific page based on
    their username or to the same page with dynamic content based on
    their username?

  • Login Session Variable Problem

    I've created a simple login using the inbuilt DW suite, but I don't seem to be able to display the session variable after they login.
    On the success page it should filter the RS based on the Username and also display the Username etc on the page but nothing is shown. I tested the success page in DW and entered a value for the session var and it works fine, all I can think of is that the session is empty, not coming through, but I'm clueless.
    Any ideas?
    <<<<<LOGIN PAGE>>>>>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      session_start();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    if (isset($_POST['UserName'])) {
      $loginUsername=$_POST['UserName'];
      $password=$_POST['Password'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "login_successful.php";
      $MM_redirectLoginFailed = "login.php";
      $MM_redirecttoReferrer = true;
      mysql_select_db($database_connpbxlogin, $connpbxlogin);
      $LoginRS__query=sprintf("SELECT UserName, UserPassword FROM Users WHERE UserName=%s AND UserPassword=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $connpbxlogin) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        //declare two session variables and assign them
        $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;     
        if (isset($_SESSION['PrevUrl']) && true) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
        header("Location: " . $MM_redirectLoginSuccess );
      else {
        header("Location: ". $MM_redirectLoginFailed );
    ?>
    <<<<<SUCCESS PAGE>>>>>
    $colname_LoggedRS = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_LoggedRS = $_SESSION['MM_Username'];
    mysql_select_db($database_connpbxlogin, $connpbxlogin);
    $query_LoggedRS = sprintf("SELECT * FROM Users WHERE UserName = %s", GetSQLValueString($colname_LoggedRS, "text"));
    $LoggedRS = mysql_query($query_LoggedRS, $connpbxlogin) or die(mysql_error());
    $row_LoggedRS = mysql_fetch_assoc($LoggedRS);
    $totalRows_LoggedRS = mysql_num_rows($LoggedRS);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    </p>
    <p>username: <?php echo $row_LoggedRS['UserFirstName']; ?></p>
    <p>email: <?php echo $row_LoggedRS['UserEmail']; ?></p>
    <p>Session Data:
      <?php echo $_SESSION['MM_Username']; ?></p>
    </body>
    </html>
    <?php
    mysql_free_result($LoggedRS);
    ?>

    Does your success page begin with session_start()?

  • Accessing session variables PHP

    I am trying to access a session variable from a log in form (using the Log In User Server Behavior) and am lost. I simply want to display the users information in the target page. I read in another discussion that I had to bind the variable to the target page, which I did, but that didn't fix it.
    Please help.
    Here is my loginFormAction code:
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      session_start();
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    if (isset($_POST['email'])) {
      $loginUsername=$_POST['email'];
      $password=$_POST['password'];
      $MM_fldUserAuthorization = "";
      $MM_redirectLoginSuccess = "owner.php";
      $MM_redirectLoginFailed = "register.php";
      $MM_redirecttoReferrer = false;
      mysql_select_db($database_petriever, $petriever);
      $LoginRS__query=sprintf("SELECT email, password FROM owners WHERE email=%s AND password=%s",
        GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
      $LoginRS = mysql_query($LoginRS__query, $petriever) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        //declare two session variables and assign them
        $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;      
        if (isset($_SESSION['PrevUrl']) && false) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
        header("Location: " . $MM_redirectLoginSuccess );
      else {
        header("Location: ". $MM_redirectLoginFailed );
    ?>

    Wherever you want to display the logged-in username simply place this on the first line of a .php page to start the session:
    <?php session_start(); ?>
    Then place this code wherever you want to display the username:
    <?php echo $_SESSION['MM_Username']; ?>

  • Accessing session variables with php

    I am trying to access the  session variable  $_SESSION['MM_Username']  in one of my php pages, but it is somehow showing empty (i.e it does not contain the username that was entered during login).
    I checked and confirmed that my login.php function is properly setting the MM_Username session variable by echoing it  from the login function.
    So why can't I read it from another php file in the same session?  Do I need to do something else before the session variables can
    be properly read from any php file in the same session?  Any help would be appreciated.

    Here is a test code I am using to access the session variable $_SESSION['MM_username']  from  the php page  test.php. But it is not working.
    I get an empty string all the time for $username. Can any one see something wrong with this code?
    <?php require_once('Connections/MyTestingConn.php'); ?>
    <?php session_start(); ?>
    <?php
    $username = "-1";
    if (isset($_SESSION['MM_username'])) {
      $username = $_SESSION['MM_username'];
      echo $username;
    else
       echo "Eror: can not access session variable";
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Test</title>
    </head>
    <body>
    </body>
    </html>

  • Dreamweaver need to create a session variable or Cookie or something Help

    I have been working for weeks I am very close but can't get over one last hurdle. I am trying to call a session variable much like dreamweaver calls mm_username. It is in the same user table as username - password - access level - Customer_id. I need to pull the session variable or cookie or however I can do it to access the customer id number so I can have customer specific information and pricing. There will be mulitple users for each customer so I need another variable besides mm_username. Help I use dreamweaver cs4 aspvbscript and sqlserver ...help

    I soon as I put the red line of code in it is custoemr _id instead of user id in my table. Dreamweaver removes the user id function. is it in the wrong place ...what am i doning wrong ....it is fine with the first part you did but the second part it doesnt like in red.
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <!--#include virtual="/Connections/p21.asp" -->
    <%
    ' *** Validate request to log in to this site.
    MM_LoginAction = Request.ServerVariables("URL")
    If Request.QueryString <> "" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
    MM_valUsername = CStr(Request.Form("username"))
    If MM_valUsername <> "" Then
      Dim MM_fldUserAuthorization
      Dim MM_redirectLoginSuccess
      Dim MM_redirectLoginFailed
      Dim MM_loginSQL
      Dim MM_rsUser
      Dim MM_rsUser_cmd
      MM_fldUserAuthorization = "Access_Level" 
      MM_redirectLoginSuccess = "/mainmenu.asp" 
      MM_redirectLoginFailed = "/loginfailed.asp" 
      MM_loginSQL = "SELECT customer_id, Login_Name, password"
      If MM_fldUserAuthorization <> "" Then MM_loginSQL = MM_loginSQL & "," & MM_fldUserAuthorization
      MM_loginSQL = MM_loginSQL & " FROM dbo.btb_web_login WHERE Login_Name = ? AND password = ?"
      Set MM_rsUser_cmd = Server.CreateObject ("ADODB.Command")
      MM_rsUser_cmd.ActiveConnection = MM_p21_STRING
      MM_rsUser_cmd.CommandText = MM_loginSQL
      MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param1", 200, 1, 20, MM_valUsername) ' adVarChar
      MM_rsUser_cmd.Parameters.Append MM_rsUser_cmd.CreateParameter("param2", 200, 1, 10, Request.Form("password")) ' adVarChar
      MM_rsUser_cmd.Prepared = true
      Set MM_rsUser = MM_rsUser_cmd.Execute 
      If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
        ' username and password match - this is a valid user
        Session("MM_Username") = MM_valUsername
        Session ("MM_USERID") = MM_rsUser.Fields.Item("customer_id").value
        If (MM_fldUserAuthorization <> "") Then
          Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
        Else
          Session("MM_UserAuthorization") = ""
        End If
        if CStr(Request.QueryString("accessdenied")) <> "" And false Then
          MM_redirectLoginSuccess = Request.QueryString("accessdenied")
        End If
        MM_rsUser.Close
        Response.Redirect(MM_redirectLoginSuccess)
      End If
      MM_rsUser.Close
      Response.Redirect(MM_redirectLoginFailed)
    End If
    %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Brown Live Online Login</title>
    <style type="text/css">
    <!--
    body {
        background-image: url(/images/gradientblacktowhite.jpg);
        background-repeat: repeat-x;
    .style1 {
        color: #FFFFFF;
        font-weight: bold;
    .style3 {color: #000000; font-weight: bold; }
    .style5 {
        font-size: xx-large;
        color: #0000FF;
    .style6 {color: #000000}
    -->
    </style></head> 
    <body>
    <p class="style5"><img src="/images/BTBlogosmall.jpg" width="322" height="53" /></p>
    <p class="style5">Brown Live Online 2.0 </p>
    <form ACTION="<%=MM_LoginAction%>" id="form1" name="form1" method="POST">
      <p>
        <label><span class="style3">    User Name</span>
        <input name="username" type="text" id="username" size="20" />
        </label>
      </p>
      <p>
        <label><span class="style1"><span class="style6">Password</span></span>
        <input name="password" type="password" id="password" size="20" />
        </label>
      </p>
      <p>
        <label>
        <input type="submit" name="button" id="button" value="Login" />
        </label>
      </p>
    </form>
    <p><a href="/index.html"><img src="/images/brown2.0.jpg" width="100" height="100" /></a> Click Image to return to <a href="http://www.browntransmission.com">www.browntransmission.com</a></p>
    </body>
    </html>

  • Update Session Variable; Username changed

    Hello...
    My session variable for my website is MM_Username.
    After logging into my website, the user can change his/her
    username if desired.
    I can successfully create the update record form, and after
    the user changes the username, the "myinfo" page is shown.
    Of course, the session variable is no longer linked to this
    user so no information is shown.
    Upon changing the username, how can I get my session
    variable, "MM_Username" to be attached to this new changed
    username?
    Thanks!!!!!

    $_SESSION['MM_Username'] = newusername; // (in PHP)
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "chris.cavage" <[email protected]> wrote in
    message
    news:gimuiu$2vf$[email protected]..
    > Hello...
    >
    > My session variable for my website is MM_Username.
    >
    > After logging into my website, the user can change
    his/her username if
    > desired.
    >
    > I can successfully create the update record form, and
    after the user
    > changes
    > the username, the "myinfo" page is shown.
    >
    > Of course, the session variable is no longer linked to
    this user so no
    > information is shown.
    >
    > Upon changing the username, how can I get my session
    variable,
    > "MM_Username"
    > to be attached to this new changed username?
    >
    > Thanks!!!!!
    >

  • Problem with Threads and a static variable

    I have a problem with the code below. I am yet to make sure that I understand the problem. Correct me if I am wrong please.
    Code functionality:
    A timer calls SetState every second. It sets the state and sets boolean variable "changed" to true. Then notifies a main process thread to check if the state changed to send a message.
    The problem as far I understand is:
    Assume the timer Thread calls SetState twice before the main process Thread runs. As a result, "changed" is set to true twice. However, since the main process is blocked twice during the two calls to SetState, when it runs it would have the two SetState timer threads blocked on its synchronized body. It will pass the first one, send the message and set "changed" to false since it was true. Now, it will pass the second thread, but here is the problem, "changed" is already set to false. As a result, it won't send the message even though it is supposed to.
    Would you please let me know if my understanding is correct? If so, what would you propose to resolve the problem? Should I call wait some other or should I notify in a different way?
    Thanks,
    B.D.
    Code:
    private static volatile boolean bChanged = false;
    private static Thread objMainProcess;
       protected static void Init(){
            objMainProcess = new Thread() {
                public void run() {
                    while( objMainProcess == Thread.currentThread() ) {
                       GetState();
            objMainProcess.setDaemon( true );
            objMainProcess.start();
        public static void initStatusTimer(){
            if(objTimer == null)
                 objTimer = new javax.swing.Timer( 1000, new java.awt.event.ActionListener(){
                    public void actionPerformed( java.awt.event.ActionEvent evt){
                              SetState();
        private static void SetState(){
            if( objMainProcess == null ) return;
            synchronized( objMainProcess ) {
                bChanged = true;
                try{
                    objMainProcess.notify();
                }catch( IllegalMonitorStateException e ) {}
        private static boolean GetState() {
            if( objMainProcess == null ) return false;
            synchronized( objMainProcess ) {
                if( bChanged) {
                    SendMessage();
                    bChanged = false;
                    return true;
                try {
                    objMainProcess.wait();
                }catch( InterruptedException e ) {}
                return false;
        }

    Thanks DrClap for your reply. Everything you said is right. It is not easy to make them alternate since SetState() could be called from different places where the state could be anything else but a status message. Like a GREETING message for example. It is a handshaking message but not a status message.
    Again as you said, There is a reason I can't call sendMessage() inside setState().
    The only way I was able to do it is by having a counter of the number of notifies that have been called. Every time notify() is called a counter is incremented. Now instead of just checking if "changed" flag is true, I also check if notify counter is greater than zero. If both true, I send the message. If "changed" flag is false, I check again if the notify counter is greater than zero, I send the message. This way it works, but it is kind of a patch than a good design fix. I am yet to find a good solution.
    Thanks,
    B.D.

  • Error while offsetting a variable

    Hello Experts
    I want to display the data for last 5 years in my query. So I tried using the SAP exit variable Current Calendar Year (0CYEAR) and the offset it by 5. However, I am getting the following error message for the query "System error in program SAPLRR12 and form REP_ASSIGN_INITIAL_OPT-01"
    Any Help on this is appreciated and points will be assigned.
    Thanks

    Thanks Chetan for your prompt reply. I have assigned points.
    But I would appreciate if you help me clear my understanding of offseting a variable.
    Say if the Current Calendar Year variable returns 2008, then will offseting that variable by 5 return me the data for years 2008, 2007, 2006, 2005 , 2004. Or, will it just return me the data for 2008 - 5 = 2004 only.
    Thanks
    Rishi

Maybe you are looking for

  • Collect Message without correlation

    Hi, I have a scenario. I have to collect 10 files which has like 100 bytes of information in each file and they should be collected into a single file every five minutes. I dont know whats inside the file. The data may vary...How  do I collect these

  • Doubt on condition in P.O

    In PO item detail condition, enter the conditions what we need EX discount, surcharge, freight etc.... after made GR. I need to display and show some of the condition types in PO as separate line. what setting have to do?

  • Problem with ACS 4.2 Database replication

    Greetings, I am not able to replicate Database between two ACS SE 4.2. I am getting the following error: Inbound database replication from ACS 'ACS_BEX_001' denied - shared secret mismatch. The configuration apparently is ok. I am attaching the confi

  • Problems deploying sounds with jar/game

    I've almost finished my game, for as far as software can ever be finished. Now I've troubles creating a jar file that contains all of the game's resources. Within my IDE (Eclipse) the game finds & plays .wav files correctly using: for(int i = 0; i< n

  • Save and open with applet?

    Hi, This is a quite urgent problem.... I have uploaded an applet onto my web page. It takes an image as input, embosses it and displays it. At the moment the input is a text field that takes a url. I want to create an upload or open file button as we