User Login Specific Page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
redzonne
Forum Newbie
Posts: 8
Joined: Sun Mar 06, 2005 12:27 pm
Location: Los Angeles

User Login Specific Page

Post 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]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uh.. $_SESSION['valid_user'] or $HTTP_SESSION_VARS['valid_user'], not $login on line 6 of the posted code.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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]
Czar
Forum Commoner
Posts: 58
Joined: Sun Dec 29, 2002 11:17 am

Post 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. )
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

fetch_array() returns both numeric and named indices by default.
Post Reply