-2
私はログインを試みていますが、readrecord()funtionの最初の行に "uncaught typeerror:undefined"それを解決する方法を知っている。uncaught typeerror:未定義のプロパティ 'action'を設定できません
<script>
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();
}}
</script>
<?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 '<script> Userdontexist(); </script>';
}
} // end else
} // end if
?>
<tr>
<td style="width: 95px;">Username</td>
<td dir="rtl" style=" text-align: center; width: 195px;">
<form method="post" target="_blank">
<input id="Traveler_Username" type="text" dir="rtl" size="10" />
</form>
</td>
<td> </td>
</tr>
<tr>
<td></td>
<td class="he_shadow" style="text-align: center; width: 70px;"> </td>
<td style="width: 95px;">Password</td>
<td dir="rtl" style=" text-align: center; width: 195px;">
<form method="post" target="_blank">
<input id="Password" name="Password" type="password" dir="rtl" size="10" />
</form>
</td>
<td></td>
</tr>
<tr>
<td rowspan="2"> </td>
<td style="text-align: center; width: 70px;" rowspan="2">
</td>
<td style="width: 95px" rowspan="2">
<form method="post" target="_blank">
<input name="Submit1" type="submit" value="login" onclick="readrecord()" style="width: 43px" />
</form></td>
<td style="text-align: center; border-bottom-color: #FF9900; width: 195px; height: 30px;">
<input name="Reset1" type="reset" value="clear data" /></td>
<td rowspan="2"> </td>
</tr>
<tr>
<td style="text-align: center; border-bottom-color: #FF9900; width: 195px;">
</td>
</tr>
<tr>
<td> </td>
<td style="text-align: center; width: 70px;">
</td>
<td style="width: 95px">
</td>
<td style="text-align: center; border-bottom-color: #FF9900; width: 195px;">
</td>
<td> </td>
</tr>
</div>
コードを変更する必要がありますか?
明らかに 'document.main'はありません。どうしてでしょうか、どこかに定義しましたか? – adeneo
代わりにjqueryを使う – bader
'document.main'は'