When I am fetching the row it not fetch array I want to know if I want to display the user name in session what should I have to do. This is the code I am checking for user name and if user name is found returning the name of user but it could not display.
Please help me or suggest me any better way. Thanks. error code: function
public function Check_login($uname,$pass)
{
//echo $uname;
$check=mysql_query("select name from user where name='$uname' and password='$pass'");
$log=mysql_fetch_row($check);
$abc=mysql_fetch_array($check);
echo $abc['name'];
if($log>0)
{
$_SESSION['login']=1;
echo $_SESSION['name']=$abc['name'];
return $_SESSION['name'];
}
else
{
return false;
}
home page:
<?php
session_start();
include('function.php');
$user=new user();
if(!$user->get_session())
{
header("location:index.php");
}
if($_GET['q']=='logout')
{
$user->logout();
header("location:index.php");
}
?>
here is html code:
<h1>All Information</h1>
Welcome<?php echo $_SESSION['name']; ?></br>
<a href="?q=logout">Logout</a>`enter code here`