按 HTML 按钮截断 MySQL table

Truncate MySQL table by pressing HTML button

我正在尝试创建一个 HTML 按钮,当按下时,它会截断 MySQL table。我使用了 here 给出的答案。 该按钮有效,但问题是当我刷新页面时,命令被触发并且 table 被截断,即使我没有按下截断按钮。我该如何解决?我只有一个 .php 文件。

目前的代码是:

<?php
$dbc = mysqli_connect('localhost', 'username', '', 'DB_name')
  or die('Error connecting to MySQL server.');
?>

<form method="post" action="<?php mysqli_query($dbc, 'TRUNCATE TABLE `my_table`')   ?>">
    <input name="submit_button" type="submit" value=" Truncate Table " />
</form>

我不会认为我的问题是重复的,因为在另一个问题中,有一个重定向到另一个 .php 页面。

使用类似这样的东西

<?php
$dbc = mysqli_connect('localhost', 'username', '', 'DB_name') or die('Error connecting to MySQL server.'); 
if(isset($_POST['submit_button']))
{
    mysqli_query($dbc, 'TRUNCATE TABLE `my_table`');
    header("Location: " . $_SERVER['PHP_SELF']);
    exit();
}

?>
<form method="post" action="">
    <input name="submit_button" type="submit" value=" Truncate Table " />
</form>