can anyone tell mewhere im wrong i wana get if user login it should display user logged in and if admin login it should disaply admin logged in ...but its displaying nothing who so ever logged in.need r suggestion
database is as follows
uid | username | password | name | type
--------+----------+----------+-------------------+-------
on | man | preet |t singh | user
onto | nio | gdic | onio | admin
<?php
$username = $POST["username"];
$password = $POST["password"];
$connection = pg_connect("dbname=test user=ev host=localhost ") or die("Cannot connect
to server");
$result = pg_query($connection, "select type from ontestusers where username='$username' and password='$password' ") or die("Cannot execute the query");
$no_rows = pg_num_rows( $result ); // if only one row correct username and pwd
if($no_rows == 1)
{ //testing purpose
//echo "In IF NO OF ROWS ".$result['type'];
//echo "In IF NO OF ROWS ".$no_rows;
if ($result['type'] == 'user' )
{
//echo $result['type'];
echo "User";
}
elseif($result['type'] == 'admin' )
{
// echo $result['type'];
echo "ADMIN";
}
}
else
{
echo "Username and pwd wrong...";
}
?>