ここで私のコードに問題があります。どうしてか分かりません。
<h2>Delete Admins</h2><br/>
<?php
$con=mysqli_connect("localhost","root","","poll");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM admin");
echo "<table>
<tr>
<th>ID</th>
<th>Username</th>
<th>Action</th>
</tr>";
?>
<form name="form1" method="POST" action="del-all.php?id=<?php echo $row['admin_id'] ?>" />
<?php
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['admin_id'] . "</td>";
echo "<td>" . $row['login'] . "</td>";
echo "<td><button>DELETE</button></td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
</form>
これは、データを送信する del-all.php です。エラーがフォームにあるのか、<ボタン>にあるのか、「エコー」にあるのか、アクションにあるのか、それともメソッドにあるのかわかりません
del-all.php
<?php
require_once('auth.php');
?>
<?php
$id =$_REQUEST['id'];
$con=mysqli_connect("localhost","root","","poll");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"DELETE FROM admin WHERE admin_id = '$id'");
mysqli_close($con);
?>
<html>
<head>
<title>Successfully Deleted!</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="../style.css" rel="stylesheet" type="text/css" />
<link href='../fonts/fonts.css' rel='stylesheet' type='text/css'>
<script type="text/JavaScript">
<!--
setTimeout("location.href = 'index.php';",1500);
-->
</script>
</head>
<body>
<fieldset>
<h1 style="color:white;">
Data Deleted Successfully!
</h1>
</fieldset>
</body>
</html>