nano Posted March 1, 2008 Share Posted March 1, 2008 Hey, I have tried to search but I found it hard as I am not sure what I am searching Just a quickie really - If I have created a session from the login $_SESSION['email'] It is obvisouly checking the user table at the login page. If I wanted to then have a members page that lists all of the users details, how would I go about this? Could I for example do: <?php include("database/database.php"); $id=$_SESSION['email']; $row = mysql_fetch_array(mysql_query("select * from user_system WHERE email = $id")); ?> Then print the information like: {$row['email']} I have had a play but can't get it working, any help would be appreciated. Cheers. Quote Link to comment Share on other sites More sharing options...
shocker-z Posted March 1, 2008 Share Posted March 1, 2008 you need session_start(); at the top of yopu page where you create $_SESSION['email'] and every page you wish to carry it over to. see http://uk.php.net/manual/en/function.session-start.php Regards Liam Quote Link to comment Share on other sites More sharing options...
nano Posted March 1, 2008 Author Share Posted March 1, 2008 Yeah I have session_start(); my question was probably a little messy Just once a user has logged in correctly, how can I display all of their information. Cheers. Quote Link to comment Share on other sites More sharing options...
ILYAS415 Posted March 1, 2008 Share Posted March 1, 2008 how did u try to echo your information? plz show the script =) Quote Link to comment Share on other sites More sharing options...
nano Posted March 1, 2008 Author Share Posted March 1, 2008 That is my question, I think.. I want to know how to echo the details of the user table after a user has logged in Quote Link to comment Share on other sites More sharing options...
QuietWhistler Posted March 1, 2008 Share Posted March 1, 2008 Why don't you just use: print( $row[ "email" ] ); etc? Simple as that right? Quote Link to comment Share on other sites More sharing options...
ILYAS415 Posted March 1, 2008 Share Posted March 1, 2008 Okay lets try fetching object instead array... <?php include("database/database.php"); $id= $_SESSION['email']; $row = mysql_fetch_object(mysql_query("select * from user_system WHERE email = $id")); ?> You would echo information like this... <? echo "$row->email"; ?> or Your email: <?= $row->email ?> Quote Link to comment Share on other sites More sharing options...
nano Posted March 1, 2008 Author Share Posted March 1, 2008 Yeah thanks, problem is the code looks fine to me but it still doesn't seem to work. I have run simular code on different pages and it works perfect :-\ <?php session_start(); if (!isset($_SESSION['email'])){ header("Location:login.php"); exit(); } include("database/database.php"); $user = $_SESSION['email']; $info = mysql_fetch_object(mysql_query("select * from user_system WHERE email = $user")); ?> <a href='account.php' class='toollink'><? echo "$info->email"; ?></a> No errors, just nothing.. I also can't print or echo $info - not sure if that is normal. Thanks Quote Link to comment Share on other sites More sharing options...
nano Posted March 1, 2008 Author Share Posted March 1, 2008 Ok I found the problem, and for anyone else who might have a simular issue: The variables in the SQL statement have to be in quotes, otherwise it will treat the '@' as a like argument (from the email address) so result: $info = mysql_fetch_array(mysql_query("select * from user_system WHERE email = '$user'")); and to echo: {$info['email']} Thanks for the help Quote Link to comment Share on other sites More sharing options...
ILYAS415 Posted March 2, 2008 Share Posted March 2, 2008 lool didnt se that it was sooo obvious Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.