我的php代码没有更新或添加到数据库

我的php代码没有更新或添加到数据库,php,Php,基本上,我没有得到任何错误,当我按下更新或添加。有人能帮我吗?我需要它,所以当我按add时,它会将数据添加到数据库中,当我按update时,它会用该值更新数据库 <html> <head> <title>Subcontractors Data</title> </head> <body> <a href="index.html">Logout</a> <a href="homepage.htm

基本上,我没有得到任何错误,当我按下更新或添加。有人能帮我吗?我需要它,所以当我按add时,它会将数据添加到数据库中,当我按update时,它会用该值更新数据库

<html>
<head>
<title>Subcontractors Data</title>
</head>

<body>
<a href="index.html">Logout</a>
<a href="homepage.html">Homepage</a>
<?php
//make connection
$con = mysqli_connect("localhost","root","");

if(!$con){
    die("Can not connect " . mysqli_error());
}

//select db
mysqli_select_db($con , 'subcontractor');


$sql="SELECT * FROM subcontractors";



if(isset($_POST['update'])){
    $UpdateQuery = "UPDATE subcontractors SET ID='$_POST[ID]', Name='$_POST[Name]', Surname='$_POST[Surname]', FPA='$_POST[FPA]', Performance='$_POST[Performance]' WHERE ID='$_POST[hidden]'";
    mysqli_query($con, $UpdateQuery);


};

if(isset($_POST['add'])){
    $AddQuery = "INSERT INTO subcontractors (ID, Name, Surname, FPA, Performance) VALUES ('$_POST[aID]','$_POST[aName]','$_POST[aSurname]','$_POST[aFPA]','$_POST[aPerformance]')";
    mysqli_query($con, $AddQuery);

};

$my_Data=mysqli_query($con,$sql);

echo "<table border=1>";
  echo"<tr>";
    echo"<th>ID</th>";
    echo"<th>Name</th>";
    echo"<th>Surname</th>";
    echo"<th>FPA</th>";
    echo "<th>Performance</th>";
  echo "</tr>";

 while($record=mysqli_fetch_assoc($my_Data)){
 echo "<form action=editsub.php method=post>";
 echo "<tr>";   
 echo "<td>" . "<input type=text name='ID' value=".$record['ID'] ." </td>";
 echo "<td>" . "<input type=text name='Name' value=".$record['Name'] . " </td>";
 echo "<td>" . "<input type=text name='Surname' value=".$record['Surname'] . " </td>";
 echo "<td>" . "<input type=text name='FPA' value=".$record['FPA'] . "% </td>";
 echo "<td>" . "<input type=text name='Performance' value=".$record['Performance'] . "% </td>";
 echo "<input type=hidden name='hidden' value=" . $record['ID'] . ">";
 echo "<input type=submit name='update' value='update'>";
 echo "</tr>";
 echo "</form>";
 }
 echo "<form action=editsub.php mehtod=post>";
 echo "<tr>";
 echo "<td><input type=text name='aID'></td>";
 echo "<td><input type=text name='aName'></td>";
 echo "<td><input type=text name='aSurname'></td>";
 echo "<td><input type=text name='aFPA'></td>";
 echo "<td><input type=text name='aPerformance'></td>";
 echo "<td>" . "<input type=submit name='add' value='add'" . " </td>";
 echo "</form>";

 echo "</table>";
mysqli_close($con);
?>



</body>




</html>

分包商数据

这样您就可以检查错误

ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

第一种,
方法
!=<代码>方法
。第二,请使用事先准备好的声明,你会受到注射攻击。第三,这是不是
editsub.php
?第四,确认查询实际上正在运行,最后,检查