简体   繁体   English

当我单击按钮时,我想更新数据库

[英]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.

相关问题 我想更新数据库中的一栏,点击投票按钮 - I want to update the one column in database on click the vote button 甜蜜警报(我想在单击甜蜜警报确认按钮时将数据库状态(默认值:待定)更新为确认) - sweet alert (i want to update database status (default:pending) into confirm when i click sweet alert confirm button 我想用按钮做一些功能。 我想要当我单击按钮时将显示结果。 结果来自数据库 - i want to do some functions with button. i want when i click on button it will be show result. result comes from database 当我使用 codeigniter 3.x 单击视图文件中的按钮时,我想插入数据库 - I want to insert in database when I click a button in my View file using codeigniter 3.x 我想在单击按钮时生成bool值 - I want to generate a bool value when I click a button 我想使用php更新数据库(mysql)中单选按钮的值 - I want to update a value of radio button in database (mysql) using php 更新数据库时,我不想更新所有列 - When update database I don't want update all columns 我想当我点击模态上的单选按钮(objectart)时,它应该在另一个 div(objecttype)中更改模态上的其他 div 数据(获取数据库) - i want when i click on radio button (objectart) on modal then it should change other div data (fetch database) on modal in another div(objecttype) 我有一个点击数据库中的按钮 -1 每次我想要点击第二次 +1 - i have a button on click -1 in database in Every time i want on click second +1 当我点击提交按钮时数据不会更新 - Data does not update when i click on submit button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM