单击按钮时更新MySQL

时间:2016-03-22 20:14:50

标签: button sql-update

编辑:Fred -ii-,我一直在查看您引用的页面以解决我的问题( PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset")但是我看不到任何与Mmy问题有关的内容,请你详细说明一下吗?

我一直在尝试设置我的代码,这样一旦你点击一个按钮它就会更新我的数据库中的一个字段,但是它似乎没有做任何事情,我对php很新,任何帮助都会非常感谢。

(某些连接信息,如$ username已更改为更通用的格式)。

<?php
$username = "username";
$password = "password";
$host = "localhost";
$db = $username;
$connection = connect($host, $username, $password, $db);

    if(isset($_POST["PSol"]))
    {
        $sql = "UPDATE MK1 SET Sol='Progress' WHERE id = 1";
        if (mysqli_query($connection, $sql)) {
            echo "success";
        } else {
            echo "Error: " . $sql . "<br>" . mysqli_error($connection);
        }

        mysqli_close($connection);
        echo "<p>Disconnected from server: ".$host."</p>";
    }
?>
<form action = "" method = "POST" name = "PSolCanvas" class = "PSolCanvas">
    <input name = "PSol" type = "button" class = "PSol" value = "P"/>
</form>

0 个答案:

没有答案