Highlighted

Cannot pass value of Session("MM_username")

New Here ,
May 19, 2020

Copy link to clipboard

Copied

I am working in PHP and havev built a basic Log in page which contains a form for the user to enter Username and Password. Using the Server Behavior "log in User" it is supose to validate these two fields against a PHP MYSQL database. After enter the form data and submitting it the correct behaviors thus validating the data. When I pass it to another page to call the full record data using the two entered fields it does not work. I have spent hours debugging and from what I can see is the Session variable MM_username  is not getting set. Below is the code for the entry form:

 

Login_test.php

 

<?php require_once('Connections/localhost.php'); ?>
<?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;
}
}
?>
<?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 = "test_username.php";
  $MM_redirectLoginFailed = "unauthorize.html";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_localhost, $localhost);
 
  $LoginRS__query=sprintf("SELECT user_name, password FROM user_info WHERE user_name=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  
  $LoginRS = mysql_query($LoginRS__query, $localhost) 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 );
  }
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
 
 
    
<form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST">
  <table width="50%" border="0">
    <tbody>
      <tr>
        <th width="48%" align="right" scope="row">User Name:</th>
        <td width="52%"><input type="text" name="username" id="username"></td>
        </tr>
      <tr>
        <th align="right" scope="row">Password:</th>
        <td><input type="text" name="password" id="password"></td>
        </tr>
      <tr>
        <th align="right" scope="row">&nbsp;</th>
        <td>&nbsp;</td>
        </tr>
      <tr>
        <th align="right" scope="row">&nbsp;</th>
        <td><input type="submit" name="submit" id="submit" value="Login"></td>
        </tr>
      <tr>
        <th align="right" scope="row"><a href="registration.php">Create New Account</a></th>
        <td>&nbsp;</td>
        </tr>
      </tbody>
    </table>
  <p>&nbsp;</p>
</form>
           
</body>
</html>
 
Here is the code for the test_username.php file.
 
 
<?php require_once('Connections/localhost.php'); ?>
<?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_Recordset1 = "-1";
if (isset($_SESSION['MM_username'])) {
  $colname_Recordset1 = $_SESSION['MM_username'];
}
mysql_select_db($database_localhost, $localhost);
$query_Recordset1 = sprintf("SELECT * FROM user_info WHERE user_name = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!doctype html>
<html>
<?php require "header.php"; ?>
<?php
mysql_free_result($Recordset1);
?>
<!doctype html>
 <head></head>
 <body>
 <?php
     if (isset($_SESSION["MM_username"])) {
         $loggenOnUser = $_SESSION["MM_username"];
         echo "Found User: ", $loggenOnUser, "<br />";
     } else {
         $loggenOnUser = " a public user";
     }
 ?>
     <div class="gridContainer clearfix">
         <div id="div1" class="fluid">
             This page is being called by my login.php file.
         </div>
         <div id="LoggedInUser" class="fluid ">
             Hi.  I'm <?php echo $loggenOnUser; ?>
         </div>
         <img id="homeImage"  src="images/home.gif" /> </div>
     </div>
 </body>
</html>
 
If anyone has an idea that I can try please let me know. Thanks!

Views

529

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Cannot pass value of Session("MM_username")

New Here ,
May 19, 2020

Copy link to clipboard

Copied

I am working in PHP and havev built a basic Log in page which contains a form for the user to enter Username and Password. Using the Server Behavior "log in User" it is supose to validate these two fields against a PHP MYSQL database. After enter the form data and submitting it the correct behaviors thus validating the data. When I pass it to another page to call the full record data using the two entered fields it does not work. I have spent hours debugging and from what I can see is the Session variable MM_username  is not getting set. Below is the code for the entry form:

 

Login_test.php

 

<?php require_once('Connections/localhost.php'); ?>
<?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;
}
}
?>
<?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 = "test_username.php";
  $MM_redirectLoginFailed = "unauthorize.html";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_localhost, $localhost);
 
  $LoginRS__query=sprintf("SELECT user_name, password FROM user_info WHERE user_name=%s AND password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
  
  $LoginRS = mysql_query($LoginRS__query, $localhost) 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 );
  }
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
 
 
    
<form ACTION="<?php echo $loginFormAction; ?>" id="form1" name="form1" method="POST">
  <table width="50%" border="0">
    <tbody>
      <tr>
        <th width="48%" align="right" scope="row">User Name:</th>
        <td width="52%"><input type="text" name="username" id="username"></td>
        </tr>
      <tr>
        <th align="right" scope="row">Password:</th>
        <td><input type="text" name="password" id="password"></td>
        </tr>
      <tr>
        <th align="right" scope="row">&nbsp;</th>
        <td>&nbsp;</td>
        </tr>
      <tr>
        <th align="right" scope="row">&nbsp;</th>
        <td><input type="submit" name="submit" id="submit" value="Login"></td>
        </tr>
      <tr>
        <th align="right" scope="row"><a href="registration.php">Create New Account</a></th>
        <td>&nbsp;</td>
        </tr>
      </tbody>
    </table>
  <p>&nbsp;</p>
</form>
           
</body>
</html>
 
Here is the code for the test_username.php file.
 
 
<?php require_once('Connections/localhost.php'); ?>
<?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_Recordset1 = "-1";
if (isset($_SESSION['MM_username'])) {
  $colname_Recordset1 = $_SESSION['MM_username'];
}
mysql_select_db($database_localhost, $localhost);
$query_Recordset1 = sprintf("SELECT * FROM user_info WHERE user_name = %s", GetSQLValueString($colname_Recordset1, "text"));
$Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<!doctype html>
<html>
<?php require "header.php"; ?>
<?php
mysql_free_result($Recordset1);
?>
<!doctype html>
 <head></head>
 <body>
 <?php
     if (isset($_SESSION["MM_username"])) {
         $loggenOnUser = $_SESSION["MM_username"];
         echo "Found User: ", $loggenOnUser, "<br />";
     } else {
         $loggenOnUser = " a public user";
     }
 ?>
     <div class="gridContainer clearfix">
         <div id="div1" class="fluid">
             This page is being called by my login.php file.
         </div>
         <div id="LoggedInUser" class="fluid ">
             Hi.  I'm <?php echo $loggenOnUser; ?>
         </div>
         <img id="homeImage"  src="images/home.gif" /> </div>
     </div>
 </body>
</html>
 
If anyone has an idea that I can try please let me know. Thanks!

Views

530

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 19, 2020 0
Adobe Community Professional ,
May 19, 2020

Copy link to clipboard

Copied

What is the version of

1. your Dreamweaver

2. the PHP on the server

 

To give you an idea of where I am heading, the PHP version of your code is 

PHP_VERSION < 6

 


Ben

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 19, 2020 0
New Here ,
May 19, 2020

Copy link to clipboard

Copied

Dreamweaver 19.2

php 5.6

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 19, 2020 0
Adobe Community Professional ,
May 19, 2020

Copy link to clipboard

Copied

The deprecated Server Behavior Panels are no longer fit for use.  Why do you insist on using them after we told you not to?  And to make matters worse, you have legacy FluidGrid Layouts which Adobe abandoned 6 years ago. 

Nancy_OShea_1-1588967747848.png

This project is not getting off to a good start.

 

Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 19, 2020 0
New Here ,
May 19, 2020

Copy link to clipboard

Copied

Nancy;

 

Why is the Server Behavior Panel part of the software? If the panel exists one should expect it to work correctly. What are the solutions for those activities found on that panel? I.E. What is the solution for the Login Page? As far as the structure, in the past I used tables for format structure in the past. Yes, I have been away for some 4 years but I thought table structure would work the same? Multiple strange things have been happening, such as removing a portion of code and the view portion of the split screen did not update. The only solutoin I could find was to close the file and reopen it to get the view portion of the screen to work. Are there any other portions of the software that to do not work? Please let me know. Thanks!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 19, 2020 0
Adobe Community Professional ,
May 20, 2020

Copy link to clipboard

Copied

The code you're working with appears to have originated in Creative Suite 6, not DW CC 2019.  

Use discontinued software at your own risk.

 

FluidGrid Layouts were removed from Dreamweaver CC as were the deprecated Server-Behavior Panels.  If you installed the SB panels extension yourself, that's on you.  See screenshot from DMX Zone's website.

https://www.dmxzone.com/go/21842/enable-server-behaviors-and-data-bindings-panel-support-for-dreamwe...

image.png

 

Nancy O'Shea, ACP
Alt-Web.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 20, 2020 0