PHP login problem
<p>I have the following code. Now when I press the login button nothing happens and the username and password are cleared.</p>

<pre><code>&lt;?php
    session_start();
    $host="localhost"; // Host name
    $username="root"; // Mysql username
    $password=""; // Mysql password
    $db_name="csduc"; // Database name
    $tbl_name="students"; // Table name

    // Connect to server and select databse.
    $connect=mysql_connect("$host", "$username", "$password") or die("cannot connect");
    mysql_select_db("$db_name") or die("cannot select DB");

    // username and password sent from form
    $myusername=$_POST['username'];
    $mypassword=$_POST['password'];

    // To protect MySQL injection (more detail about MySQL injection).

    $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql,$connect);
    $row=mysql_fetch_array($result);

    // Mysql_num_row is counting table row.
    //$count=mysql_num_rows($result);
    // If result matched $myusername and $mypassword, table row must be 1 row.

    if($row)
    {
        // Register $myusername, $mypassword and redirect to file "login_success.php".
        session_register("myusername");
        session_register("mypassword");
        header("location: main.php");
    }
    else
    {
        echo "Wrong Username or Password";
    }
?&gt;
</code></pre>

<p>How can I solve this?</p>
