2023-09-02T06:09:39.png
2023-09-02T06:10:25.png

<!DOCTYPE html>
<html>
<head>
    <title>验证账号密码并执行事件</title>
</head>
<body>
    <?php
    //账号
    $content = "12";
    // 密码
    $password = "1";

    // 检查表单提交
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // 获取用户输入的密码
        $inputPassword = $_POST["password"];

        // 验证密码是否正确
        if ($inputPassword == $password) {
            // 获取用户输入的内容
            $content = $_POST["content"];
            $con = $_POST["password"];

            // 创建新元素
            echo "<p>密码正确!<br>账号为:{$content}<br>密码为:{$con}</p>";
        } else {
            echo "<p>密码错误!</p>";
        }
    }
    ?>

    <!-- 表单 -->
    <form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>">
        
        <label for="content">请输入账号:</label>
        <input type="text" id="content" name="content"><br><br>
        
        <label for="password">请输入密码:</label>
        <input type="password" id="password" name="password" required><br><br>
        

        <input type="submit" value="提交">
    </form>
</body>
</html>