How can I use database with javascript? : <pre><code>&lt;script&gt;
    function process_Login(){
        var c = document.getElementById("usr").value;
        var d = document.getElementById("pwd").value;
        if(c.length==0){
            alert("ERROR: Your ID account is NULL");
        }
        else if(isNaN(c)){
            alert("ERROR: Your ID must be number");
        }
        else
        {
            $con = mysql_connect("localhost", "root", "");
            if(!$con){
                die("cound not connect");
            }
            //select database
            mysql_select_db("db_atmvisual");
            $query = mysql_query("SELECT * FROM tb_account WHERE account_id='c' AND account_pin='d'");
            $row = mysql_num_rows($query);
            if($row!=0){
                window.location = "http://127.0.0.1:8080/atmvisual/processlogin.php";
            }
            else
                alert("loginfail");
            }
        }
&lt;/script&gt;
</code></pre>

<p>I'm trying use javascript to connect my code with sql, but I don't know why it doesn't run! if it's ok it'll change to the other page, else it'll print an alert! Can you tell me my error? and how can I improve my code?</p>
