Page 1 of 1

User Login Specific Page

Posted: Tue Mar 08, 2005 11:27 pm
by redzonne
I have implemented PHP Sessions successfully on my login page. Now, I would like to have a user control panel(members only page) were user specific info from the database would be displayed, based on the active USER specific session.

On the login page session variable is:

Code: Select all

$HTTP_SESSION_VARS ['valid_user'] = $login;
login is also a column fire in the database.

Here is a simplified version of the panel(members only page)

Code: Select all

<?
session_start();

$db = mysql_connect ( 'localhost', 'FAKE_LOGIN', 'FAKE_PASSWORD' );
mysql_select_db ( 'realest1_proppost', $db);
$result = mysql_query("SELECT * FROM customerindex WHERE login='$login'",$db);
$myrow = mysql_fetch_array($result);
echo "First Name: ".$myrow["cfirstname"];
echo "<br />";
echo "Last Name: ".$myrow["clastname"];
echo "<br />";
echo "Email Address: ".$myrow["cemail"];
echo "<br />";
echo "Login: ".$myrow["login"];
?>
The page is not showing the user specific info only:
First Name:
Last Name:
Email Address:
Login:

Any suggestions?


feyd | hey look at that,

Code: Select all

works. [/color]

Posted: Tue Mar 08, 2005 11:32 pm
by feyd
uh.. $_SESSION['valid_user'] or $HTTP_SESSION_VARS['valid_user'], not $login on line 6 of the posted code.

Posted: Tue Mar 08, 2005 11:38 pm
by pleigh
how bout changing this line

Code: Select all

$HTTP_SESSION_VARS ['valid_user'] = $login;
to

Code: Select all

$login = $HTTP_SESSION_VARS['valid_user'];
so this code

Code: Select all

$result = mysql_query("SELECT * FROM customerindex WHERE login='$login'",$db);
can be used....

does it make sense? :)


feyd | hey look at that,

Code: Select all

works. [/color]

Posted: Thu Mar 10, 2005 6:05 am
by Czar

Code: Select all

$result = mysql_query("SELECT * FROM customerindex WHERE login='$login'",$db);
$myrow = mysql_fetch_array($result);
echo "First Name: ".$myrow["cfirstname"];
echo "<br />";
You are using mysql_fetch_array(), but you are calling the variables by field names. Change mysql_fetch_array to mysql_fetch_assoc(), or call the variables by array numbers ([0],[1], etc. )

Posted: Thu Mar 10, 2005 8:18 am
by feyd
fetch_array() returns both numeric and named indices by default.