Not able to log in in PHP
<p>I have to make a simple site which you can log in and out of, and if the user is logged in they see some features which they otherwise would not. I have a DB with different names and I have a form in my index.php file...I want to enter name and password and if they're correct I want to log in (login.php),if they're not - I want to show some message.
So...this is my code (in login.php), but everytime when I enter some correct name and password from the DB it shows "0Wrong name or password!"
How can I fix it?</p>

<pre><code>&lt;?php

$username = trim($_POST['username']);
$password = sha1(trim($_POST['password']));

//Perform SQL
$querystring = "SELECT * FROM users WHERE name = '{$username}' AND  password = '{$password}'";
$result = mysql_query($querystring) or die(mysql_error());

echo mysql_num_rows($result);

if (mysql_num_rows($result) == 1) {
    $found_user = mysql_fetch_array($result);
    $_SESSION['id'] = $found_user['id'];
    $_SESSION['name'] = $found_user['username'];

    echo "Hello" . $_SESSION['username'];
} else {
    //Fail
    $message = 'Wrong name or password ! ';
    echo $message;
}
?&gt;
</code></pre>
