uncaught typeerror:cannot set property 'action' of undefined
<p>I am trying to do a login, however receive "uncaught typeerror:cannot set property 'action' of undefined" error on the first line in readrecord() funtion and don't know how to solve it.</p>

<pre><code>&lt;script&gt;
    function readrecord() {
    document.main.action = "Login.php";
    document.getElementById("op").value = "check";
    document.main.submit(); 
}

function Userdontexist() {
  alert("Username or Password is wrong");
}

function submitForm() {
    Traveler_Username = document.getElementById('Traveler_Username').value;
    Password = document.getElementById('Password').value;

        if (Traveler_Username == "" || Password == "") {
            alert("Need to fill al the fields");
            return;
      } else {
        readrecord();
}}
&lt;/script&gt;

&lt;?php
include 'DB_connection.php';
    if (isset($_REQUEST["op"])) $op = $_REQUEST["op"]; else  $op = "";
    if (isset($_REQUEST["Traveler_Username"])) $Traveler_Username = $_REQUEST["Traveler_Username"]; 
    if (isset($_REQUEST["Password"])) $Password = $_REQUEST["Password"];

if ($op=="check") {
    $query = "select * from users where Traveler_Username =".$Traveler_Username;
        $result = mysql_query($query) or die('Query failed: ' . mysql_error());
        if (mysql_num_rows($result) == 0 ){
            alert("User do not exist");
            $Traveler_Username  = "";
            $Password   = "";
            header("Location: reg.php");
            exit;
        } else {
                $query = "select Password from users where Traveler_Username =".$Traveler_Username;
                $result = mysql_query($query) or die('Query failed: ' . mysql_error());
                $row = mysql_fetch_array($result);
                $db_pass = $row["Password"];
                if ($Password == $db_pass){
                    $Traveler_Username = $row['Traveler_Username'] ;
                    $Password = $row['Password'] ;
                    } else {
                            echo '&lt;script&gt; Userdontexist(); &lt;/script&gt;';
                    }
            } // end else
} // end if

?&gt;
                &lt;tr&gt;
                &lt;td style="width: 95px;"&gt;Username&lt;/td&gt;
                &lt;td dir="rtl" style=" text-align: center; width: 195px;"&gt;
                &lt;form method="post" target="_blank"&gt;
                &lt;input id="Traveler_Username" type="text" dir="rtl" size="10" /&gt;
                    &lt;/form&gt;
                &lt;/td&gt;
                &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
                &lt;td&gt;&lt;/td&gt;
                &lt;td class="he_shadow" style="text-align: center; width: 70px;"&gt;&amp;nbsp;&lt;/td&gt;
                &lt;td style="width: 95px;"&gt;Password&lt;/td&gt;
                &lt;td dir="rtl" style=" text-align: center; width: 195px;"&gt;
                &lt;form method="post" target="_blank"&gt;                
                    &lt;input id="Password" name="Password" type="password" dir="rtl" size="10" /&gt;
                    &lt;/form&gt;
                &lt;/td&gt;
                &lt;td&gt;&lt;/td&gt;
            &lt;/tr&gt;

            &lt;tr&gt;
                &lt;td rowspan="2"&gt;&amp;nbsp;&lt;/td&gt;
                &lt;td style="text-align: center; width: 70px;" rowspan="2"&gt;
                &amp;nbsp;&lt;/td&gt;
                &lt;td style="width: 95px" rowspan="2"&gt;
                &lt;form method="post" target="_blank"&gt;
                &lt;input name="Submit1" type="submit" value="login"  onclick="readrecord()" style="width: 43px" /&gt;
                &lt;/form&gt;&lt;/td&gt;
                &lt;td style="text-align: center; border-bottom-color: #FF9900; width: 195px; height: 30px;"&gt;
                &lt;input name="Reset1" type="reset" value="clear data" /&gt;&lt;/td&gt;
                &lt;td rowspan="2"&gt;&amp;nbsp;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td style="text-align: center; border-bottom-color: #FF9900; width: 195px;"&gt;
                &amp;nbsp;&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                &lt;td style="text-align: center; width: 70px;"&gt;
                &amp;nbsp;&lt;/td&gt;
                &lt;td style="width: 95px"&gt;
                &amp;nbsp;&lt;/td&gt;
                &lt;td style="text-align: center; border-bottom-color: #FF9900; width: 195px;"&gt;
                &amp;nbsp;&lt;/td&gt;
                &lt;td&gt;&amp;nbsp;&lt;/td&gt;
            &lt;/tr&gt;

&lt;/div&gt;
</code></pre>

<p>What do I have to change in the code?</p>