吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2866|回复: 56
上一主题 下一主题
收起左侧

[其他转载] PHP+SQLite简易版仓库管理系统

[复制链接]
跳转到指定楼层
楼主
kissfox 发表于 2026-4-24 13:58 回帖奖励
本帖最后由 kissfox 于 2026-4-24 14:03 编辑

前几天接到朋友的电话说要帮忙写个简易版的仓库管理系统,于是我就日夜兼行的写了个PHP+SQLite简易版仓库管理系统强调、强调、强调
个人编写后利用deepseek+Lingma+Qoder等AI工具进行UI优化



# 仓库管理系统
📋 系统架构
一切准备工作完成后初始化数据库init_db.php
http://*********/init_db.php
初始化完成后就能整使用了
┌─────────────────────────────────────────────┐
│          仓库出入库管理系统               │
├─────────────────────────────────────────────┤
│                                  │
│             前端界面 (5个页面)                                 │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐       │
│  │   登录页面   │  │        首页     │  │  入库管理       │       │
│  └──────────┘  └──────────┘  └──────────┘       │
│  ┌──────────┐  ┌──────────┐                          │
│  │   出库管理      │  │  后台管理    │                          │
│  └──────────┘  └──────────┘                          │
│                                                                  │
├─────────────────────────────────────────────┤
│            后端逻辑 (PHP)                                                      │
│        用户认证  会话管理  CSRF保护                                  │
│        数据验证  业务逻辑  操作日志                                   │
├─────────────────────────────────────────────┤
│  数据库 (SQLite)                                              │
│   users          - 用户表                                  │
│   products       - 商品表                                  │
│   stock_in       - 入库记录表                               │
│   stock_out      - 出库记录表                             │
│   stock_history  - 库存历史表                              │
│   operation_logs - 操作日志表                              │
└─────────────────────────────────────────────┘




[PHP] 纯文本查看 复制代码
<?php
require_once 'config.php';

// 如果已登录,跳转到首页
if (isset($_SESSION['user_id'])) {
    header('Location: index.php');
    exit;
}

$error = '';

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

    if (empty($username) || empty($password)) {
        $error = '请输入用户名和密码';
    } else {
        try {
            $db = getDB();
            $stmt = $db->prepare('SELECT * FROM users WHERE username = ?');
            $stmt->execute([$username]);
            $user = $stmt->fetch();

            if ($user && verifyPassword($password, $user['password'])) {
                // 先记录日志(在设置session之前)
                try {
                    $stmt = $db->prepare('INSERT INTO operation_logs (user_id, username, operation, details, created_at) VALUES (?, ?, ?, ?, datetime("now"))');
                    $stmt->execute([$user['id'], $user['username'], 'login', '用户登录系统']);
                } catch (Exception $e) {
                    // 日志记录失败不影响登录
                    error_log('登录日志记录失败: ' . $e->getMessage());
                }
                
                // 设置会话
                session_regenerate_id(true); // 防止会话固定攻击
                $_SESSION['user_id'] = $user['id'];
                $_SESSION['username'] = $user['username'];
                $_SESSION['role'] = $user['role'];
                
                // 重定向到首页
                header('Location: index.php');
                exit;
            } else {
                $error = '用户名或密码错误';
                // 记录登录失败
                try {
                    $stmt = $db->prepare('INSERT INTO operation_logs (user_id, username, operation, details, created_at) VALUES (?, ?, ?, ?, datetime("now"))');
                    $stmt->execute([0, $username, 'login_failed', '登录失败']);
                } catch (Exception $e) {
                    error_log('登录失败日志记录失败: ' . $e->getMessage());
                }
            }
        } catch (PDOException $e) {
            $error = '系统错误,请稍后重试';
            error_log('登录错误: ' . $e->getMessage());
        }
    }
}
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>仓库管理系统 - 登录</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .login-container {
            background: white;
            padding: 40px;
            border-radius: 10px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
            width: 100%;
            max-width: 400px;
        }

        .login-header {
            text-align: center;
            margin-bottom: 30px;
        }

        .login-header h1 {
            color: #333;
            font-size: 28px;
            margin-bottom: 10px;
        }

        .login-header p {
            color: #666;
            font-size: 14px;
        }

        .form-group {
            margin-bottom: 20px;
        }

        .form-group label {
            display: block;
            margin-bottom: 8px;
            color: #333;
            font-weight: 500;
        }

        .form-group input {
            width: 100%;
            padding: 12px 15px;
            border: 2px solid #e0e0e0;
            border-radius: 5px;
            font-size: 14px;
            transition: border-color 0.3s;
        }

        .form-group input:focus {
            outline: none;
            border-color: #667eea;
        }

        .error-message {
            background: #fee;
            color: #c33;
            padding: 10px 15px;
            border-radius: 5px;
            margin-bottom: 20px;
            font-size: 14px;
        }

        .btn-login {
            width: 100%;
            padding: 12px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 5px;
            font-size: 16px;
            font-weight: 500;
            cursor: pointer;
            transition: transform 0.2s, box-shadow 0.2s;
        }

        .btn-login:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
        }

        .btn-login:active {
            transform: translateY(0);
        }

        .login-footer {
            text-align: center;
            margin-top: 20px;
            color: #999;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div class="login-container">
        <div class="login-header">
            <h1>&#128230; 仓库管理系统</h1>
            <p>Warehouse Management System</p>
        </div>

        <?php if ($error): ?>
            <div class="error-message"><?php echo htmlspecialchars($error); ?></div>
        <?php endif; ?>

        <form method="POST" action="">
            <div class="form-group">
                <label for="username">用户名</label>
                <input type="text" id="username" name="username" required autofocus autocomplete="username">
            </div>

            <div class="form-group">
                <label for="password">密码</label>
                <input type="password" id="password" name="password" required autocomplete="current-password">
            </div>

            <button type="submit" class="btn-login">登 录</button>
        </form>

        <div class="login-footer">
            <p>默认账号: admin / admin123</p>
        </div>
    </div>
</body>
</html>


简易版仓库管理系统.rar (37.37 KB, 下载次数: 279, 售价: 2 CB吾爱币)

免费评分

参与人数 8吾爱币 +8 热心值 +7 收起 理由
穿越你的灵魂 + 1 + 1 感谢分享
吾爱科学 + 1 + 1 热心回复!
xiakor + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
wuloveyou + 1 + 1 我很赞同!
tvewang + 1 + 1 值得表扬的奉献精神
beibianyu + 1 鼓励转贴优秀软件安全工具和文档!
chenyw + 1 + 1 用多维表实现,跑区域使用要方便些
小姐夫 + 1 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

推荐
 楼主| kissfox 发表于 2026-5-11 09:20 |楼主
aoveso 发表于 2026-5-11 07:40
能不能把部署所需要的软件打包发一下

软件是phpstudy_pro,也叫小皮
具体使用方法
如使用本地phpstudy

请将PHP扩展中的Pod_SQlite和Sqlite3打钩
一切准备工作完成后初始化数据库init_db.php
http://*********/init_db.php
初始化完成后就能整使用了
推荐
ziyouzhiyi503 发表于 2026-5-3 20:32
不是很懂编程的我,尝试着下载了这个项目,并一步步通过DeepSeek解决问题,最终成功布置了项目,并查看到了数据库信息,谢谢楼主的项目文件!

PixPin_2026-05-03_20-30-56.png (150.73 KB, 下载次数: 4)

使用查看数据库

使用查看数据库
沙发
35925 发表于 2026-4-24 14:10
3#
a2523188267 发表于 2026-4-24 14:15
感谢大佬分享, 先收藏改天再测试一下细化的功能如何。可以本地页面使用的吧
4#
wpdzdx 发表于 2026-4-24 14:17
是本地化部署吗
5#
小姐夫 发表于 2026-4-24 14:22
不错, 不错, 这个可以试试
6#
huarui2026 发表于 2026-4-24 14:23
感谢分享。试试呢
7#
XIAOYU2028 发表于 2026-4-24 14:28
试用下,谢谢!
8#
wszdanywl 发表于 2026-4-24 14:31
感谢楼主分享
9#
jun269 发表于 2026-4-24 15:18
看这个应该是本地化部署的,谢谢分享
10#
datian2025 发表于 2026-4-24 15:35
赞 继续 加油
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-5-17 03:06

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表