Jump to content

Pulling Info from Users table During Login


lilman

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.