php login script not giving expected result, or any
<p>i have a php login script which is accessed with a simple form:</p>

<pre><code>&lt;?php
session_start();
try{
    $user = 'root';
    $pass = null;
    $pdo = new PDO('mysql:host=localhost; dbname=divebay;', $user, $pass);

    if(isset($_SESSION['loggedin'])){

        echo "1"; //already logged in
    }


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

        $ucheck = $pdo-&gt;prepare('SELECT * FROM user WHERE username = ?');
        $ucheck-&gt;bindValue(1, $username);
        $ucheck-&gt;execute();

        if($ucheck-&gt;fetch(PDO::FETCH_OBJ)){
            $stmt = $pdo-&gt;prepare('SELECT * FROM user WHERE username = ? AND password = ?');
            $stmt-&gt;bindValue(1, $username);
            $stmt-&gt;bindValue(2, $password);

            if($stmt-&gt;fetch(PDO::FETCH_OBJ)){
                $row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);

                $_SESSION['username'] = $row['username'];
                $_SESSION['loggedin'] = 'YES';
                $_SESSION['location'] = $row['location'];
                echo "2"; //logged in

            }
            else{
                echo "3"; //password incorrect
            }
        }
        else{
            echo "4"; //user does not exist
        }

    }
}catch(PDOException $e){
    echo $e-&gt;getMessage();
}

?&gt;
</code></pre>

<p>but when i attempt to run it using an account that i just created and have confirmed to exist within the database, i get no response from this script. i would expect it to echo 2 given that the login information is correct, but i get nothing</p>

<p>can anyone suggest what ive done wrong here?</p>
