Copy link to clipboard
Copied
Hi, I hope someone here can help me.
I'm using Dreamweaver CS4 with PHP and what I'm trying to do is to build a site feature where my users can log in using their Email and Password and go to their User Profile on a DYNAMIC PAGE and ONLY see their information displayed.
I have a log in form that works.
I have a Recordset for my Users table
I have a Update Record form on my User Profile.
The problem I'm having is that when a user logs in, it doesn't show their details, it only shows the FIRST ID user. (UserID 1) instead of the specific Loged in user.
How do I bind the log in form in a Session Variable to display the correct record on the User Update Profile page? I'd like to use both variables to bring up the user data, email address (username) and password.
The session variables set in the log in page at the moment are:
if (isset($_POST['Email:'])) {
$loginUsername=$_POST['Email:'];
$password=$_POST['Password'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index.php";
$MM_redirectLoginFailed = "Login.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_localhost, $localhost);
$LoginRS__query=sprintf("SELECT UserEmail, UserPassword FROM users WHERE UserEmail=%s AND UserPassword=%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 = "";
//declare two session variables and assign them
$_SESSION['MM_Username'] = $loginUsername;
$_SESSION['MM_UserGroup'] = $loginStrGroup;
I'm confused because my login (username) is an email address.
My Update page currently has the following code:
<?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 = "Login.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;
}
?>
I've tried filtering records both on the log in page and the update page (in the Recordset), but haven't gotten the result I'm looking for. It either shows the wrong record, or shows nothing at all.
Any help would be appreciated.
Tom
Copy link to clipboard
Copied
On update page create a filtered recordset where session variable = MM_Username to have the logged in users info available on the page.
Copy link to clipboard
Copied
Thanks for your response.
I've tried that. My settings are:

I'm using the email address as a Username, that's why I have it in the Filter. But I've also tried to use the UserID and neither works.
I tried having the Session variable to UserEmail as well, that didn't work either.
What should be in the Filter?
On the update page I have the Dreamweaver update data wizard generated table. Is that correct or should I have formatted the form in another manner?

Thanks for your help,
Tom
Copy link to clipboard
Copied
Your image shows a filtered recordset where UserEmail = Entered Value MM_Username. I am quite sure I said to make a filtered recordset where SessionVariable = MM_Username, not entered value.
Copy link to clipboard
Copied
You did...
And it was... but for some reason it shows up as Entered Values.
When I tried it, it was Session Variable.
I took 2 screenshots, both turned out as Entered Values. No idea how that happened.
Tom
Copy link to clipboard
Copied
If u use userEmail as the username, then if u apply this
Filter: userEmail > Session Variable > MM_Username
it should be fine.. Have u tried to test it first before u click OK ?
Copy link to clipboard
Copied
Hi,
Yeah, I tested it, but if I use anything but UserID, no data shows.
And when I run it, nothing shows up in the table.
When I filter it by UserID, I get the first record, or if I Sort it differently, I get one of the other records. But never the one I need (logged in user profile).
No idea what it could be.
Any help would be very much appreciated.
Tom
Find more inspiration, events, and resources on the new Adobe Community
Explore Now