Files
7.5inch_Multifunctional_E-P…/html/process.php
2023-05-27 17:17:44 +08:00

99 lines
2.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
include 'db.php';
// 处理提交留言请求
if ($_POST['action'] == 'add') {
// $name = $_POST['name'];
$sql = "SELECT COUNT(*) as count FROM daiban";
$result = $conn->query($sql);
if ($result) {
$row = $result->fetch_assoc();
$count = $row['count'];
// 如果记录数大于等于6则禁止添加新待办事项并弹出提醒
if ($count >= 10) {
echo "<script>alert('已达到最多10条待办事项');window.location.href='index.php';</script>";
} else {
// 否则,插入新的待办事项
$thing = $_POST['thing'];
$sql = "INSERT INTO daiban (thing) VALUES ('$thing')";
if ($conn->query($sql) === TRUE) {
header("Location: index.php");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
// 处理删除留言请求
if ($_GET['action'] == 'delete') {
$id = $_GET['id'];
$sql = "DELETE FROM daiban WHERE id=$id";
if ($conn->query($sql) === TRUE) {
header("Location: index.php");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
// 处理设为精选请求
if ($_GET['action'] == 'isimp') {
$id = $_GET['id'];
$sql = "UPDATE daiban SET isimp=1 WHERE id=$id";
if ($conn->query($sql) === TRUE) {
header("Location: index.php");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
// 处理取消设为精选请求
if ($_GET['action'] == 'notimp') {
$id = $_GET['id'];
$sql = "UPDATE daiban SET isimp=0 WHERE id=$id"; // 将isimp字段更新为0
if ($conn->query($sql) === TRUE) {
header("Location: index.php");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
// 完成
if ($_GET['action'] == 'isdone') {
$id = $_GET['id'];
$sql = "UPDATE daiban SET isdone=1 WHERE id=$id"; // 将isimp字段更新为0
if ($conn->query($sql) === TRUE) {
header("Location: index.php");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
// 未完成
if ($_GET['action'] == 'notdone') {
$id = $_GET['id'];
$sql = "UPDATE daiban SET isdone=0 WHERE id=$id"; // 将isimp字段更新为0
if ($conn->query($sql) === TRUE) {
header("Location: index.php");
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
$conn->close();
?>