It looks like your user table will contain a family ID. It
also looks like
you're already creating a family table recordset, filtered by
username - is
this correct? In this section:
$query_rsFamily, we can see that you are filtering your
rsFamily recordset
by your username - does this work? I'm guessing no as it
looks like you're
tryign to filter it via the SERVER variable, which hasn't
been created yet.
Instead, look for this variable: ($_POST['username'])), or
filter by form
results with the name 'username'.
If changing that works for you, then below that, (next to
this code:)
//declare two session variables and assign them
> $_SESSION['MM_Username'] = $loginUsername;
> $_SESSION['MM_UserGroup'] = $loginStrGroup;
Modify it to look like this:
//declar session variables
$_SESSION['MM_Username']=$loginUsername;
$_SESSION['MM_UserGroup']=$loginStrGroup;
$_SESSION['MM_Family']=$row_rsFamily['FamilyID'];
And you should then have your session variable set for your
family, where
$row_rsFamily is the call to your family ID. You will then be
able to sort
queries according to your FamilyID by sorting for the session
variable
MM_Family.
You mentioned wondering why MM was in the front - that's for
Macromedia.
You can replace it for whatever, but I suggest just using it
(and the naming
convention if you wish, as I did for MM_Family).
Let me know where that puts you,
Jon
"Elfkonig" <webforumsuser@macromedia.com> wrote in
message
news:efrq9s$ngj$1@forums.macromedia.com...
>I have attached the code of my login page. How do I
filter it by Username
>and
> then how do I create the relationship between Username
and the FamilyID so
> that
> in the pages that follow, the only content that shows is
that which
> matches the
> FamilyID.
>
> In other words, at which point do I switch the session
variable from being
> "MM_Username" to it being "MM_id_Family_fam"? (I don't
know by the way
> where
> the "MM_" comes from. I assume it is a PHP default, but
I don't yet
> understand
> the mechanics of it.)
>
> Please forgive my very rudimentary understanding of the
code.
>
>
CODE:
>
> <?php
require_once('../../Connections/connCasyDB.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;
> }
> }
>
> $colname_rsFamily = "-1";
> if (isset($_SESSION[''MM_Username''])) {
> $colname_rsFamily = (get_magic_quotes_gpc()) ?
> $_SESSION[''MM_Username''] :
> addslashes($_SESSION[''MM_Username'']);
> }
> mysql_select_db($database_connCasyDB, $connCasyDB);
> $query_rsFamily = sprintf("SELECT * FROM es_family WHERE
Username = %s",
> GetSQLValueString($colname_rsFamily, "text"));
> $rsFamily = mysql_query($query_rsFamily, $connCasyDB) or
> die(mysql_error());
> $row_rsFamily = mysql_fetch_assoc($rsFamily);
> $totalRows_rsFamily = mysql_num_rows($rsFamily);
> ?>
> <?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 = "id_usertype";
> $MM_redirectLoginSuccess = "listing.php";
> $MM_redirectLoginFailed = "loginFailed.php";
> $MM_redirecttoReferrer = true;
> mysql_select_db($database_connCasyDB, $connCasyDB);
>
> $LoginRS__query=sprintf("SELECT Username, Password,
id_usertype FROM
> es_family WHERE Username=%s AND Password=%s",
> GetSQLValueString($loginUsername, "text"),
GetSQLValueString($password,
> "text"));
>
> $LoginRS = mysql_query($LoginRS__query, $connCasyDB) or
> die(mysql_error());
> $loginFoundUser = mysql_num_rows($LoginRS);
> if ($loginFoundUser) {
>
> $loginStrGroup = mysql_result($LoginRS,0,'id_usertype');
>
> //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 );
> }
> }
> ?><!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>Sign Up Form</title>
> </head>
>
> <body>
> <form id="signup" name="signup" method="POST"
action="<?php echo
> $loginFormAction; ?>">
> <label for="username">Username:</label>
> <p>
> <input type="text" name="username" id="username"
/>
> </p>
> <p>
> <label for="password">Password:</label>
> <input type="password" name="password" id="password"
/>
> </p>
> <p>
> <input type="submit" name="Submit" value="Sign In"
/>
> </p>
> </form>
> </body>
> </html>
> <?php
> mysql_free_result($rsFamily);
> ?>
>