`mysql_query()` result returns blank
I made a web page where one have to login. I login, and it redirects me to
my homepage. On that page there is a heading that says "Welcome back, #my
name#!". The name should be selected from a database, using the username I
gave. The problem is that the result of the query returns blank. What's
the problem?
home.php:
$query = mysql_query("SELECT name FROM user_info WHERE username='$user'")
or die(mysql_error());
$result = mysql_fetch_array($query);
if(!$result){echo mysql_error();}
echo $result;
In home.php $user is a variable that stores $_SESSION['ande'].
login.php:
if($count==1){$_SESSION['code'] = "titan" or die(mysql_error());
$_SESSION['ande'] = $user;header("location: home.php");}
In login.php $user stores $_POST['user'], where user is the name of an
input field.
No comments:
Post a Comment