我需要使用刪除按鈕從數據庫中刪除新聞文章。我寫了所有的代碼,但它給了我錯誤注意:未定義的索引:在第5行C:\ XAMPP \ htdocs \ PortalZaVijesti \ php \ delete.php中的acticleID。我沒有看到有什麼問題,所以你可以看看我的碼? admin.php的PHP從SQL中刪除數據庫使用按鈕
$dbc = mysqli_connect("localhost", "root", "", "news_portal") or die(mysql_error());
$query = "SELECT * FROM news_site;";
$result = mysqli_query($dbc, $query);
while ($row = mysqli_fetch_assoc($result)) {
echo "<p>".$row['title'];
echo "</p>
<form action='php/delete.php' method='post' class='deletePHP'>
<input type='hidden' name='articleID' value='".$row['id']."'/>
<input type='submit' name='delete' value='delete'/>
</form>;
delete.php
$dbc = mysqli_connect("localhost", "root", "", "news_portal") or die(mysql_error());
if(isset($_POST["delete"]) && !empty($_POST["articleID"])){
$id = mysqli_real_escape_string($dbc, $_POST["acticleID"]);
}
$delquery = "DELETE FROM news_site WHERE ID='$id'";
mysqli_query($dbc, $delquery) or die(mysqli_error($dbc));
if(mysqli_affected_rows($dbc)){
echo "It was really successful.";
}