管理员将键入成员的用户名,然后单击“删除”按钮以从数据库中删除该成员
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "root", "", "phplogin");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Attempt delete query execution
$sql = "DELETE FROM users WHERE username='mrs.snowballs'";
if(mysqli_query($link, $sql)){
echo "Records were deleted successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
?>
答案 0 :(得分:0)
<form action='simple.php' method='post'>
What Name You want to delete : <input type='text' name='del'/>
<input type='submit' name='submit' value='delete'/>
</form>
现在在你的PHP中:
if(isset($_POST['submit']))
{
$name = $_POST['del'];
$link = mysqli_connect("localhost", "root", "", "phplogin");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
// Attempt delete query execution
$sql = "DELETE FROM users WHERE username='$name'";
if(mysqli_query($link, $sql)){
echo "Records were deleted successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// Close connection
mysqli_close($link);
}