豌豆Ai站群搜索引擎系统 V.25.10.25 网址:www.wd.chat

🗣 Wd提问: PHP源码打卡系统

🤖 Ai回答:
下面是一个简单的 PHP 源码打卡系统 的实现方案,适合用于学习或小团队内部的每日签到功能。该系统包含以下核心功能:

✅ 功能说明
1、用户登录(可选,也可匿名打卡)
2、每日打卡(仅限每天一次)
3、显示打卡记录(日期 + 时间)
4、数据存储:使用本地文件(`data/records.json`)或数据库(可扩展为 MySQL)

📂 项目结构

/checkin/
├── index.php 主页:显示打卡按钮和记录
├── checkin.php 打卡处理逻辑
├── login.php 登录页面(可选)
├── logout.php 登出
├── data/
│ └── records.json 存储打卡数据
└── style.css 简单样式

🔧 1、`index.php`(主页面)

php
<?php
session_start();

// 检查是否已登录(如果需要)
if (!isset($_SESSION['user'])) {
header(Location: login.php);
exit;
}

// 读取打卡记录
$recordFile = 'data/records.json';
$records = [];

if (file_exists($recordFile)) {
$json = file_get_contents($recordFile);
$records = json_decode($json, true) ?: [];
}

// 获取当前日期
$currentDate = date('Y-m-d');

// 是否已打卡
$hasCheckedIn = false;
foreach ($records as $record) {
if ($record['date'] === $currentDate && $record['user'] === $_SESSION['user']) {
$hasCheckedIn = true;
break;
}
}

?

<!DOCTYPE html
<html lang=zh
<head
<meta charset=UTF-8 /
<title打卡系统</title
<link rel=stylesheet href=style.css /
</head
<body
<div class=container
<h1📅 每日打卡系统</h1
<p<strong用户:</strong<?php echo htmlspecialchars($_SESSION['user']); ?</p

<?php if ($hasCheckedIn): ?
<div class=success✅ 已完成今日打卡!时间:<?php echo $record['time']; ?</div
<?php else: ?
<form action=checkin.php method=POST
<button type=submit name=checkin class=btn⏰ 立即打卡</button
</form
<?php endif; ?

<h2📊 打卡记录</h2
<ul class=record-list
<?php foreach ($records as $record): ?
<li
<strong<?php echo htmlspecialchars($record['user']); ?</strong
<?php echo $record['date'] ? @ <?php echo $record['time'] ?
</li
<?php endforeach; ?
</ul

<a href=logout.php class=logout登出</a
</div
</body
</html

📌 2、`checkin.php`(打卡处理)

php
<?php
session_start();

if (!isset($_SESSION['user'])) {
die(请先登录!);
}

$user = $_SESSION['user'];
$currentDate = date('Y-m-d');
$currentTime = date('H:i:s');

$recordFile = 'data/records.json';
$records = [];

// 读取已有记录
if (file_exists($recordFile)) {
$json = file_get_contents($recordFile);
$records = json_decode($json, true) ?: [];
}

// 检查是否已打卡
$alreadyChecked = false;
foreach ($records as $record) {
if ($record['date'] === $currentDate && $record['user'] === $user) {
$alreadyChecked = true;
break;
}
}

if ($alreadyChecked) {
die(<scriptalert('今天已打卡!'); window.history.back();</script);
}

// 添加新打卡记录
$records[] = [
'user' = $user,
'date' = $currentDate,
'time' = $currentTime
];

// 写入文件
if (file_put_contents($recordFile, json_encode($records, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT))) {
echo <scriptalert('打卡成功!'); window.location.href='index.php';</script;
} else {
die(保存失败,请检查权限!);
}
?

🔐 3、`login.php`(登录页,可选)

php
<?php
session_start();

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = trim($_POST['username']);
$password = $_POST['password'];

// 简单验证(实际应使用密码哈希)
if ($username === 'admin' && $password === '123456') {
$_SESSION['user'] = $username;
header(Location: index.php);
exit;
} else {
$error = 用户名或密码错误;
}
}
?

<!DOCTYPE html
<html lang=zh
<head
<meta charset=UTF-8 /
<title登录</title
<link rel=stylesheet href=style.css /
</head
<body
<div class=container
<h1🔐 登录</h1
<?php if (isset($error)): ?
<div class=error<?php echo $error; ?</div
<?php endif; ?
<form method=POST
<input type=text name=username placeholder=用户名 required /
<input type=password name=password placeholder=密码 required /
<button type=submit class=btn登录</button
</form
</div
</body
</html

🚪 4、`logout.php`

php
<?php
session_start();
session_destroy();
header(Location: login.php);
exit;
?

📁 5、`data/records.json`(初始文件)

创建目录并初始化文件:

bash
mkdir -p data
echo [] data/records.json

确保 `data/` 目录对 PHP 有写权限。

🎨 6、`style.css`

css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: Arial, sans-serif;
background-color: f4f7fa;
color: 333;
line-height: 1.6;
}

.container {
max-width: 600px;
margin: 50px auto;
padding: 30px;
background: fff;
border-radius: 10px;
box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

h1 {
text-align: center;
margin-bottom: 20px;
color: 2c3e50;
}

p {
margin-bottom: 15px;
font-size: 1.1em;
}

.btn {
display: block;
width: 100%;
padding: 12px;
background: 3498db;
color: white;
border: none;
border-radius: 5px;
font-size: 1.1em;
cursor: pointer;
transition: background 0.3s;
}

.btn:hover {
background: 2980b9;
}

.success {
background: d4edda;
color: 155724;
padding: 10px;
border-radius: 5px;
margin-bottom: 20px;
text-align: center;
}

.error {
background: f8d7da;
color: 721c24;
padding: 10px;
border-radius: 5px;
margin-bottom: 20px;
}

.record-list {
list-style: none;
margin-top: 20px;
}

.record-list li {
padding: 8px 0;
border-bottom: 1px dashed ccc;
}

.logout {
display: block;
text-align: center;
margin-top: 30px;
color: e74c3c;
text-decoration: none;
}

.logout:hover {
text-decoration: underline;
}

✅ 使用方法

1、将所有文件放入服务器(如 Apache + PHP 环境)。
2、访问 `http://localhost/checkin/login.php`
3、输入用户名:`admin`,密码:`123456`
4、进入首页后点击“立即打卡”
5、查看打卡记录

🔄 扩展建议

| 功能 | 实现方式 |

| 多用户支持 | 使用数据库(如 MySQL),表结构:`id, user, date, time` |
| 验证码 | 加入 CAPTCHA |
| 移动端适配 | 增加响应式设计 |
| 统计图表 | 用

Ai作答

📣 商家广告


姓名

广告招商

八字

月饼

豌豆Ai站群搜索引擎系统


0

IP地址: 149.223.160.131

搜索次数: 0

提问时间: 2025-11-05 22:37:10

🛒 域名购买
wenchangji.cn
ltqz.cn
n-f.cn
5.he.cn
81.biz
zv.gs
al3.net
v.jl.cn
836.net.cn
sou.gg

❓️ 热门提问
云服务器那个价格低
数据库vps
本地http服务器
phpstorm断点调试
最便宜的笔记本
c++怎么搭建服务器
nom.br域名
MySQL源码存储过程实现
云vps东京
云计算可以用来做什么
豌豆Ai站群搜索引擎系统

🌐 域名评估
tuue.cn
jagb.cn
kb.gs
vv.nx.cn
drone.sd.cn
qptj.cn
i.jx.cn
yu7.gd.cn
vegr.cn
af.cq.cn

⛏ 最新挖掘
凯里酸汤鱼
贵阳烤脑花
都匀毛尖茶
花溪牛肉粉
贵阳烤生蚝
贵阳烤豆腐
贵阳纸包鱼
贵阳特色菜

🖌 热门作画

🤝 关于我们:
豌豆Ai 域名 建站 站群 留痕 推广 评估 源码
开发Ai 工具 日记 价格 加盟 广告 流量 留言 联系

🗨 加入群聊
群

🔗 友情链接
网站搜索引擎入口  温泉度假村设计  ai提问

🧰 站长工具
Ai工具  whois查询  搜索

📢 温馨提示:本站所有问答由Ai自动创作,内容仅供参考,若有误差请用“联系”里面信息通知我们人工修改或删除。

👉 技术支持:本站由豌豆Ai提供技术支持,使用的最新版:《豌豆Ai站群搜索引擎系统 V.25.10.25》搭建本站。

上一篇 65558 65559 65560 下一篇