[英]When I click the button, I want to update the database
I want to create a process in which the database is updated by pressing the button.我想创建一个通过按下按钮更新数据库的过程。 However, when you write it like the code below, when you click the button, it goes to the
admin_cp.php
page.但是,当您像下面的代码那样编写它时,当您单击按钮时,它会转到
admin_cp.php
页面。 The page froze, and the contents of the database remained unchanged.页面冻结,数据库的内容保持不变。 What's the problem with my code?
我的代码有什么问题?
admincharge.php admincharge.php
<form action="admin_cp.php" method="POST" onsubmit="return confirm('Charging handle?');">
<input type="submit" neme="charge"/>
</form>
admin_cp.php admin_cp.php
include('Aconfig.php');
if (isset($_POST["charge"])){
$query = "UPDATE userinfo
INNER JOIN chargeINFO ON (userinfo.u_id = chargeINFO.u_id)
SET userinfo.u_charged = chargeINFO.u_chargewait;";
$result = mysqli_query($conn, $query);
if ($result) {
echo "<script>alert('Charged complete.')</script>";
echo "<meta http-equiv='refresh' content='0;url=admincharge.php'>";
} else {
echo "<script>alert('fail')</script>";
echo "<meta http-equiv='refresh' content='0;url=admincharge.php'>";
}
}
have you checked this part:你检查过这部分:
$query = "UPDATE userinfo
INNER JOIN chargeINFO ON (userinfo.u_id = chargeINFO.u_id)
SET userinfo.u_charged = chargeINFO.u_chargewait;";
at the end of.unchargewait;"; delete; so it looks like this:在.unchargewait;"; 的末尾删除;所以它看起来像这样:
$query = "UPDATE userinfo
INNER JOIN chargeINFO ON (userinfo.u_id = chargeINFO.u_id)
SET userinfo.u_charged = chargeINFO.u_chargewait";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.