我目前正在尝试获取一个表单按钮来更改MySQL数据库表字段值?有什么想法我会对此代码出错吗?...
HTML按钮:
<form><form action="admin.php" method="POST">
<strong>ACTIVE MODE -</strong> Main BaseCentre website is online and active. <input type="submit" value="Maintenance Mode" class="btn btn-default" name="updateclose_site">|
</form>
PHP脚本:
if (isset($_POST['updateclose_site'])){
$sql = mysql_query("UPDATE adminpage SET close_site='1' WHERE setting='main'");
$sql_doublecheck = mysql_query("SELECT * FROM adminpage WHERE setting='main' AND close_site='1'");
$doublecheck = mysql_num_rows($sql_doublecheck);
if($doublecheck == 0){
echo "<strong><font color=red>> Close site is off</font></strong>";
} elseif ($doublecheck > 0) {
echo "<strong><font color=green>> Close site is working</strong></font><br />";
}
}
我的数据库如下所示:
“标题”设置| close_site(枚举,0、1、2、3)
“行”主| 0(默认)
单击按钮没有任何反应?将不胜感激!
最佳答案
将html更改为
<form action="admin.php" method="POST">
<strong>ACTIVE MODE -</strong> Main BaseCentre website is online and active. <input type="submit" value="Maintenance Mode" class="btn btn-default" name="updateclose_site">|
</form>
您还有一个
<form>
关于php - 试图获取一个表单按钮来更改数据库中的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22000442/