my php code don't work result
<p>I have an issue in my php script when I enter a correct username it echo "user found" and when </p>

<p>I enter wrong user name it echo also "user found".</p>

<p>Here is my code please check and let me know, if !$result variable supposed to work but didn't. Why?.</p>

<pre><code>&lt;?php
    echo "enter the username \n";
    $username = trim(fgets(STDIN));
    echo "enter the password\n";
    $password = trim(fgets(STDIN));

    //connecting to database
    $db = mysql_connect("localhost","sqldata","sqldata") or die(mysql_error());

    //selecting our database
    $db_select = mysql_select_db("accounts", $db) or die(mysql_error());

    $result= mysql_query("select * from login where username = '$username' ");
    if (!$result)
    {
        echo "error no user";
    }
    else
    {
        echo "user found";
    }

    mysql_close($db)
?&gt;
</code></pre>
