close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

display session variable

Thread began 4/09/2010 3:14 pm by pogro711404698 | Last modified 4/13/2010 8:10 pm by Eric Mittman | 1010 views | 4 replies |

pogro711404698

display session variable

hi,
i need help on how to do this.

on my log in page, i did (server behavior > SecurityAssist authenticate user> and created a session variable first_name.

here is the code for the log in page:


<?php require_once('Connections/boulevardstyle.php'); ?>
<?php require_once('Connections/boulevardstyle.php');?>
<?php require_once('Connections/boulevardstyle.php');?>
<?php require_once('Connections/boulevardstyle.php');?>
<?php require_once( "WA_SecurityAssist/Helper_PHP.php" ); ?>
<?php
if(isset($_POST["button_x"])){
$WA_Auth_Parameter = array(
"connection" => $boulevardstyle,
"database" => $database_boulevardstyle,
"tableName" => "users",
"columns" => explode($WA_Auth_Separator,"emailaddress".$WA_Auth_Separator."password"),
"columnValues" => explode($WA_Auth_Separator,"".$row_users[''] ."".$WA_Auth_Separator."".((isset($_POST["password"]))?$_POST["password"]:"") .""),
"columnTypes" => explode($WA_Auth_Separator,"text".$WA_Auth_Separator."text"),
"sessionColumns" => explode($WA_Auth_Separator,"1st_name"),
"sessionNames" => explode($WA_Auth_Separator,"first_name"),
"successRedirect" => "index1.php",
"failRedirect" => "re_userLogIn.php",
"gotoPreviousURL" => TRUE,
"keepQueryString" => FALSE
);

WA_AuthenticateUser($WA_Auth_Parameter);
}

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;
}
}

mysql_select_db($database_boulevardstyle, $boulevardstyle);
$query_users = "SELECT * FROM users";
$users = mysql_query($query_users, $boulevardstyle) or die(mysql_error());
$row_users = mysql_fetch_assoc($users);
$totalRows_users = mysql_num_rows($users);
?>
<?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 = "";
$MM_redirectLoginSuccess = "index1.php";
$MM_redirectLoginFailed = "re_userLogin.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_boulevardstyle, $boulevardstyle);

$LoginRS__query=sprintf("SELECT emailaddress, password FROM users WHERE emailaddress=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $boulevardstyle) 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 );
}
}
?>

and this is the page code where i want the 1st name of the user to be displayed:

<?php require_once('Connections/boulevardstyle.php'); ?>
<?php require_once('Connections/boulevardstyle.php');?>
<?php require_once('Connections/boulevardstyle.php');?>
<?php require_once('Connections/boulevardstyle.php');?>
<?php

Sign in to reply to this post

pogro711404698

require_once('Connections/boulevardstyle.php');?>
<?php require_once('Connections/boulevardstyle.php');?>
<?php require_once( "WA_SecurityAssist/Helper_PHP.php" ); ?>
<?php
if(isset($_POST["button_x"])){
$WA_Auth_Parameter = array(
"connection" => $boulevardstyle,
"database" => $database_boulevardstyle,
"tableName" => "users",
"columns" => explode($WA_Auth_Separator,"emailaddress".$WA_Auth_Separator."password"),
"columnValues" => explode($WA_Auth_Separator,"".$row_users[''] ."".$WA_Auth_Separator."".((isset($_POST["password"]))?$_POST["password"]:"") .""),
"columnTypes" => explode($WA_Auth_Separator,"text".$WA_Auth_Separator."text"),
"sessionColumns" => explode($WA_Auth_Separator,"1st_name"),
"sessionNames" => explode($WA_Auth_Separator,"first_name"),
"successRedirect" => "index1.php",
"failRedirect" => "re_userLogIn.php",
"gotoPreviousURL" => TRUE,
"keepQueryString" => FALSE
);

WA_AuthenticateUser($WA_Auth_Parameter);
}

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;
}
}

mysql_select_db($database_boulevardstyle, $boulevardstyle);
$query_users = "SELECT * FROM users";
$users = mysql_query($query_users, $boulevardstyle) or die(mysql_error());
$row_users = mysql_fetch_assoc($users);
$totalRows_users = mysql_num_rows($users);
?>
<?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 = "";
$MM_redirectLoginSuccess = "index1.php";
$MM_redirectLoginFailed = "re_userLogin.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_boulevardstyle, $boulevardstyle);

$LoginRS__query=sprintf("SELECT emailaddress, password FROM users WHERE emailaddress=%s AND password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $boulevardstyle) 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"><!-- InstanceBegin template="/Templates/dynamics.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>User Log In | boulevardstyle.com</title>
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
body,td,th {
font-family: Arial, Helvetica, sans-serif;
color: #333333;

-->
</style>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<link href="boulevard_style.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style2 {color: #FF0000}
-->
</style>

<style type="text/css">
<!--
.style3 {color: #EE1C25}
.style4 {font-size: 12px}
-->
</style>
<!-- InstanceBeginEditable name="head" -->
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>

<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style7 {color: #134D92}
-->
</style>
<!-- InstanceEndEditable -->
</head>

<body>
<div id="top">
<div id="logo"><img src="images/logo.jpg" width="147" height="152" /></div>
<!-- InstanceBeginEditable name="EditRegion5" -->
<div id="dynamicInfo"><?php echo $_SESSION['first_name']; ?>| <a href="#">Your Account</a> |<a href="#"><img src="images/shopping_cart-32.png" width="34" height="30" border="0" align="absbottom" /></a> <a href="#">Cart</a> </div>
<!-- InstanceEndEditable -->
<div id="search">
<form id="form1" name="form1" method="post" action="">
<label>
<input name="search" type="text" id="search2" />
</label>
<label>
<input name="button" type="image" id="button" value="Submit" src="images/arrow_right.gif" align="bottom" />
</label>
</form>
</div>
<div id="navigation">
<ul id="MenuBar1" class="MenuBarHorizontal">
<li><a href="index.html">Boulevard Style</a> </li>
<li><a href="product_gallery.html">Product Gallery</a></li>
<li><a href="comunity_fund.html">Community Fund Raising</a> </li>
<li><a href="about_us.html">About Us</a></li>
<li><a href="contact_us.html">Contact Us</a></li>
</ul>
</div>
</div>
<div id="main">
<div id="bodypage_contact"><!-- InstanceBeginEditable name="left_nav" -->
<div id="left">
<p><strong>About Boulevard<br />
<br />
<img src="images/mail_32.gif" width="32" height="32" align="absmiddle" /> E-mail:</strong><a href="mailto:info@boulevardstyle.com">info@boulevardstyle.com</a></p>
<p>ORDER BOULEVARD FASHIONS<br />
<span class="style3">Online ordering coming soon!</span></p>
<p><a href="comunity_fund.html">Community Fund Raising</a><br />
<a href="sales_rep.html">Become a Sales Rep</a><br />
<a href="fashion_icon.html">Become a Boulevard Fashion Icon</a><br />
<a href="boulevard_community.html">Join the Boulevard Community</a><span class="style4"><br />
</span></p>
</div>
<!-- InstanceEndEditable -->
<div id="right"><!-- InstanceBeginEditable name="rightConts" -->
<div id="c_left">
<p class="style2"><span class="ShoeName style7">Log In</span><br />
</p>
<form ACTION="<?php echo $loginFormAction; ?>" id="form2" name="form2" method="POST">
<table width="331">





i dragged the session variable first_name to tha place where i want it to be displayed but i did not get any result...

any help would be highly appreciated

thanks

Sign in to reply to this post

Eric Mittman

Is the problem that you are not getting logged in, or that you are logged in and the first_name session var is not set?

I can see a couple of potential problems in your authenticate user server behavior. The first issue that I see is that you are referencing the column values like this:

php:
"columnValues" => explode($WA_Auth_Separator,"".$row_users[''] ."".$WA_Auth_Separator."".((isset($_POST["password"]))?$_POST["password"]:"") .""),



You will need to reference the username or email field from your login form instead of the empty recodset value that is currently being used.

The other thing that I noticed is that the first name column in your table is set as 1st_name, in my experience it is not a good idea to have a number starting off a column name. I'm not sure if this has any relation to the problem you are experiencing but it is something that I noticed.

Sign in to reply to this post

pogro711404698

i was able to log in, after logging in i am directed to the page i set. my problem is, i don't see that user first name where i dragged that session variable.

thanks

Sign in to reply to this post

Eric Mittman

Please post back with the login page and the page you are trying to view the value on. Please include these files in a zip archive attached to the post. I will take a look and if I need any additional info or files I will let you know.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...