我使用相当标准的HTML / PHP表单来更新MYSQL数据库中的表。当我将表单直接加载到Web浏览器中时,它可以正常工作。当我尝试通过javascript(通过一个更大的网站)加载表单时,表单显示但没有做任何事情。当我单击提交按钮时没有任何反应 - 并且在我看到的任何地方都不会生成错误。任何人都可以对此有所了解吗?
this.display_admin_table_header = function () {
current_pane.send_get_admin_table_data = this.send_get_admin_table_data;
$('#admin_tab').addClass('selected');
$('#stat_table').find('tr:gt(0)').remove();
$('#stat_table').load('form2.php'); //<--form i'm loading
}
以下是网络表单:
<html>
<head>
<?php
if(isset($_POST['update']))
{
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbname = 'my_db';
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$node = $_POST['label'];
$mode = $_POST['mode'];
$department = $_POST['department'];
$ip = $_POST['ip'];
$username = $_POST['username'];
$password = $_POST['password'];
$db = $_POST['db'];
$sql = "INSERT into device ".
"SET label = '$node' , ".
# "SET mode = $mode ".
# "SET department = $department ".
# "SET ip = $ip ".
# "SET username = $username ".
# "SET password = $password ".
"db = $db ";
error_log(" $sql \n");
if(! mysqli_query( $conn,$sql ))
{
die('Could not update data: ' . mysqli_error($conn));
}
echo "Updated data successfully\n";
mysql_close($conn);
}
else
{
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Node </td>
<td><input name="label" type="text" id="label"> </td>
</tr>
<tr>
<td width="100">Site-Bucket </td>
<td><input name="department" type="text" id="department"> </td>
</tr>
<tr>
<td width="100">Mode </td>
<td><input name="mode" type="radio" id="mode" value="1">Cmode <br>
<input name="mode" type="radio" id="mode" value="2">7mode<br> </td>
</tr>
<tr>
<td width="100">Node Man. IP </td>
<td><input name="ip" type="text" id="ip"> </td>
</tr>
<tr>
<td width="100">Username </td>
<td><input name="username" type="text" id="username"> </td>
</tr>
<tr>
<td width="100">Password </td>
<td><input name="password" type="text" id="password"> </td>
</tr>
<tr>
<td width="100">DB in use?</td>
<td><input name="db" type="radio" id="db" value=1>Yes <br>
<input name="db" type="radio" id="db" value=0>No <br> </td>
</tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="update" type="submit" id="update" value="Update">
</td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>