lilman Posted November 19, 2006 Share Posted November 19, 2006 Objective: Pull the username and gender for later reference when the user logs in. Code to Accomplish Objective:[code] $query = "SELECT * FROM users WHERE user_name='$user_name' AND password='$password'"; $result = mysql_query($query) or die("Error ". mysql_error. " with query ". $query); $rownum = mysql_num_rows($result); if($rownum==1) { for ($i=0; $i <1; $i++) { $row = mysql_fetch_array($result); session_register("user_name"); echo $_SESSION['user_name']; $gender = $row['gender']; session_register("gender"); echo "success "; }[/code]Problem: When I try to later call $_SESSION['gender'] it is empty. I have made $_SESSION['gender'] a global variable, but that doesn't fix the problem. I don't see anything wrong with the code, nor can I think of any reason as to why it isn't storing the member's gender. A little lost and could use some guidance, so if you wouldn't mind guiding me I would really appreciate it. Thank you Link to comment https://forums.phpfreaks.com/topic/27797-pulling-info-from-users-table-during-login/ Share on other sites More sharing options...
Branden Wagner Posted November 19, 2006 Share Posted November 19, 2006 what happens if you just echo $row['gender']?if that works then do this$_SESSION['gender'] = $row['gender']; Link to comment https://forums.phpfreaks.com/topic/27797-pulling-info-from-users-table-during-login/#findComment-127170 Share on other sites More sharing options...
lilman Posted November 19, 2006 Author Share Posted November 19, 2006 Thank you for your help, it worked!!! Link to comment https://forums.phpfreaks.com/topic/27797-pulling-info-from-users-table-during-login/#findComment-127190 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.