<p>以下是使用PHP和HTML代码实现的网站右下角悬浮点击按钮,点击按钮后会弹出一个新的页面,页面大小与当前浏览器窗口大小相同,页面上有一个举报提交链接的表单:</p>
<h3>index.php:</h3>
```html
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>右下角悬浮按钮</title>
    <style>
        #report-button {
            position: fixed;
            bottom: 20px;
            right: 20px;
            background-color: #f44336;
            color: white;
            padding: 10px 20px;
            border-radius: 5px;
            font-size: 16px;
            cursor: pointer;
            z-index: 9999;
        }
<pre><code>    #report-form {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 9998;
    }

    #report-form .modal-content {
        background-color: #fefefe;
        margin: 10% auto;
        padding: 20px;
        border: 1px solid #888;
        width: 80%;
    }

    #report-form .close {
        color: #aaa;
        float: right;
        font-size: 28px;
        font-weight: bold;
        cursor: pointer;
    }

    #report-form .close:hover,
    #report-form .close:focus {
        color: black;
        text-decoration: none;
        cursor: pointer;
    }
&lt;/style&gt;
</code></pre>
</head>
<body>
    <button id="report-button">举报</button>
<pre><code>&lt;div id=&quot;report-form&quot;&gt;
    &lt;div class=&quot;modal-content&quot;&gt;
        &lt;span class=&quot;close&quot;&gt;&amp;times;&lt;/span&gt;

        &lt;form action=&quot;submit_report.php&quot; method=&quot;POST&quot;&gt;
            &lt;label for=&quot;link&quot;&gt;链接:&lt;/label&gt;
            &lt;input type=&quot;text&quot; id=&quot;link&quot; name=&quot;link&quot; required&gt;

            &lt;input type=&quot;submit&quot; value=&quot;提交&quot;&gt;
        &lt;/form&gt;
    &lt;/div&gt;
&lt;/div&gt;

&lt;script&gt;
    document.getElementById(&quot;report-button&quot;).addEventListener(&quot;click&quot;, function() {
        document.getElementById(&quot;report-form&quot;).style.display = &quot;block&quot;;
    });

    document.getElementsByClassName(&quot;close&quot;)[0].addEventListener(&quot;click&quot;, function() {
        document.getElementById(&quot;report-form&quot;).style.display = &quot;none&quot;;
    });
&lt;/script&gt;
</code></pre>
</body>
</html>
```
<h3>submit_report.php:</h3>
```php
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // 处理举报提交逻辑
    $link = $_POST["link"];
<pre><code>// 在此处可以将链接进行处理和保存

// 重定向回主页或其他页面
header(&quot;Location: index.php&quot;);
exit();
</code></pre>
<p>}
?&gt;</p>
<pre><code>
&lt;p&gt;通过上述代码,我们可以在网站中添加一个名为'举报'的悬浮按钮,点击按钮后会弹出一个页面,页面上有一个用于提交举报链接的表单。用户输入链接后,点击提交按钮,表单数据将会通过POST请求提交到submit_report.php进行处理。处理完成后可以选择重定向回主页或其他页面。&lt;/p&gt;
</code></pre>
网站右下角悬浮举报按钮:PHP/HTML 实现弹出页面

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

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