以下是使用PHP和HTML编写的网站右下角悬浮按钮的代码,点击按钮会弹出弹窗,用户可以输入链接并提交,将链接保存到本地'jubao.txt'文件中。

<!DOCTYPE html>
<html>
<head>
    <title>举报链接</title>
    <style>
        #floatButton {
            position: fixed;
            bottom: 20px;
            right: 20px;
            width: 100px;
            height: 40px;
            background-color: #007bff;
            color: #fff;
            text-align: center;
            line-height: 40px;
            cursor: pointer;
            border-radius: 5px;
        }
        #floatButton:hover {
            background-color: #0056b3;
        }
        #reportForm {
            display: none;
            position: fixed;
            bottom: 80px;
            right: 20px;
            width: 300px;
            height: 150px;
            background-color: #fff;
            border: 1px solid #ccc;
            padding: 10px;
            border-radius: 5px;
        }
        #reportForm input[type="text"], #reportForm input[type="submit"] {
            width: 200px;
            margin-bottom: 10px;
        }
        #reportForm input[type="submit"] {
            background-color: #007bff;
            color: #fff;
            border: none;
            padding: 5px 10px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div id="floatButton" onclick="showReportForm()">举报链接</div>
    <div id="reportForm">
        <form method="post" action="">
            <input type="text" name="link" placeholder="链接" required><br>
            <input type="submit" value="提交">
        </form>
    </div>

    <script>
        function showReportForm() {
            document.getElementById("reportForm").style.display = "block";
        }
    </script>

    <?php
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $link = $_POST['link'];
        $file = fopen("jubao.txt", "a");
        fwrite($file, $link . "\n");
        fclose($file);
        echo '<script>alert("已举报");</script>';
    }
    ?>
</body>
</html>

这段代码创建了一个固定在网站右下角的悬浮按钮,点击按钮后会显示一个举报链接的提示框。在提示框中,用户可以输入链接,并点击提交按钮将链接存入名为'jubao.txt'的本地文件中。提交成功后会弹出提示框显示'已举报'的消息。

PHP+HTML 网站右下角悬浮按钮 - 举报链接弹窗

原文地址: http://www.cveoy.top/t/topic/HCc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录