网站右下角悬浮举报按钮:PHP/HTML 实现弹出页面
<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;
}
</style>
</code></pre>
</head>
<body>
<button id="report-button">举报</button>
<pre><code><div id="report-form">
<div class="modal-content">
<span class="close">&times;</span>
<form action="submit_report.php" method="POST">
<label for="link">链接:</label>
<input type="text" id="link" name="link" required>
<input type="submit" value="提交">
</form>
</div>
</div>
<script>
document.getElementById("report-button").addEventListener("click", function() {
document.getElementById("report-form").style.display = "block";
});
document.getElementsByClassName("close")[0].addEventListener("click", function() {
document.getElementById("report-form").style.display = "none";
});
</script>
</code></pre>
</body>
</html>
```
<h3>submit_report.php:</h3>
```php
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// 处理举报提交逻辑
$link = $_POST["link"];
<pre><code>// 在此处可以将链接进行处理和保存
// 重定向回主页或其他页面
header("Location: index.php");
exit();
</code></pre>
<p>}
?></p>
<pre><code>
<p>通过上述代码,我们可以在网站中添加一个名为'举报'的悬浮按钮,点击按钮后会弹出一个页面,页面上有一个用于提交举报链接的表单。用户输入链接后,点击提交按钮,表单数据将会通过POST请求提交到submit_report.php进行处理。处理完成后可以选择重定向回主页或其他页面。</p>
</code></pre>
原文地址: https://www.cveoy.top/t/topic/IAP 著作权归作者所有。请勿转载和采集!