PHP login function script not working
<p>It looks like I have some problem with this code. I need to pass <code>$uid</code> and <code>$password</code> to check the user. I thought I had it correct but it's still not working and I can't figure it out. I'm new to programming and your help would be greatly appreciated!  </p>

<p>update..</p>

<p>this following function works fine but when I modify it as below, it gives me bunch errors..</p>

<pre><code>public function getUser($uid, $password) {
    $result = mysql_query("SELECT * FROM users WHERE id = '$uid' AND pswd = '$password'") or die(mysql_error());

    $no_of_rows = mysql_num_rows($result);
    if ($no_of_rows &gt; 0) {

        $result = mysql_fetch_array($result);
        return $result;    

    } else {

        return false;
    }
}
</code></pre>

<p><strong>user_function.php</strong></p>

<pre><code>&lt;?php

class DB_Functions {

    private $db;

    function __construct() {

        require_once 'db_connect.php';

        $this-&gt;db = new DB_Connect();
        $this-&gt;db-&gt;connect();
    }

    public function getUser($uid, $password) {
        $stmt = $db-&gt;prepare("SELECT * FROM users WHERE id=? AND pswd=?");
        $stmt-&gt;execute(array($uid, $password));
        return $stmt-&gt;fetch();
    }

}

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

<p><strong>index.php</strong></p>

<pre><code>&lt;?php

if (isset($_POST['tag']) &amp;&amp; $_POST['tag'] != '') {

    $tag = $_POST['tag'];

    require_once 'include/db_functions.php';
    $db = new DB_Functions();

    $response = array("tag" =&gt; $tag, "success" =&gt; 0, "error" =&gt; 0);

    if ($tag == 'login') {

        // check for user
        $user = $db-&gt;getUser($_POST['id'], $_POST['pswd']);

        if ($user != false) {

            $response["success"] = 1;
            $response["user"]["id"] = $user["id"];

            echo json_encode($response);

        } else {

            $response["error"] = 1;
            $response["error_msg"] = "Incorrect email or password!";
            echo json_encode($response);
        }
</code></pre>
