环境配置
本系统采用phpstudy开发平台,采用PHP和MySQL数据库进行开发,开发工具为HBuilder。phpStudy是一个PHP调试环境的程序集成最新的
Apache+PHP+MySQL+phpMyAdmin,一次性安装,无须配置即可使用,是非常方便、好用的PHP调试环境。(其他平台均可)@@@文末有获取方式免费获取
————————————————
含sql文件
主要功能
————————————————
管理员登录
管理员注册
图书上架
图书修改
图书下架
图书查询
主要语言
PHP MySQL JavaScript CSS bootstrap框架
运行截图
- 登录
<div class="p-3 container"><h1 class='text-light d-flex justify-content-center fs-1 mt-3'style="width: 300px;margin: auto;">管理员登录</h1><div class="w-50 col-lg-6 offset-lg-3 mt-5"><form action="login.php" method="post" class="container"><div class="row mb-3"><label for="username" class="col-sm-2 col-form-label fw-bolder">用户名</label><div class="col-sm-6"><input class="form-control" id="username" type="text" placeholder="请输入用户名" name="username" required/></div><div class="col-sm-4" id="box1"></div><!-- 展示提示信息 --></div><div class="row mb-3"><label for="password" class="col-sm-2 col-form-label fw-bolder">密 码</label><div class="col-sm-6"><input class="form-control" id="password" type="password" placeholder="请输入密码" name="password" required/></div><div class="col-sm-4" id="box2"></div><!-- 展示提示信息 --></div><div class="row mb-3"><label for="checkCode" class="col-sm-2 col-form-label fw-bolder">验证码</label><div class="col-sm-6"><input class="form-control" id="checkCode" type="number" placeholder="请输入下图加法计算结果" name="checkCode" min="0" max="100" required onblur="check_code()"/></div><div class="col-sm-4" id="box3"></div><!-- 展示提示信息 --></div><div class="row mb-3"><label for="checkCode" class="col-sm-2 col-form-label fw-bolder">图 片</label><div class="col-sm-4"><img id="img" src="yanzhengma_add.php" onclick="refresh()"><br/><br/></div></div><div class="d-flex justify-content-between"><div ><a href="zhuce.html"><button type="button" class="btn btn-danger">暂无账号,点击注册</button></a></div><div ><button id="login" type="submit" class="btn btn-primary">点击登录</button>
- 注册
if($_POST){// 拿到用户输入的用户名,去数据库里面查询$sql01="select manager_username from manager_info where manager_username = ? "; // 1.1.定义sql--查询$pre01 = $conn->prepare($sql01); // 1.2.执行预处理,获取预处理结果对象$pre01->bind_param("s",$uname01); // 1.3.将字段与预处理绑定。$uname指向sql语句里面的'?'。$uname01 = $_POST["username"]; // 1.4.为参数赋值:用户名来源于注册页面的用户输入信息$pre01->execute(); // 1.5 执行查询// 如果用户名已经存在,就提示用户重新注册if($pre01->fetch()){ // 1.6判断执行结果,fetch()获取查询到的数据,如果有值就提示重名die( "该用户名已被占用,请重新注册<br/><a href='zhuce.html'>点击重新注册</a>");}else{// 1.定义sql--添加$sql02="insert into manager_info (manager_id, manager_username, manager_password) values (null, ?, ?)";// 2.执行预处理,获取预处理结果对象$pre02 = $conn->prepare($sql02);// 3.将字段与预处理绑定$pre02->bind_param("ss",$manager_username, $manager_password); // s:string i:int// 4.为参数赋值:用户,密码$manager_username = trim($_POST["username"]);$manager_password = sha1(md5(trim($_POST["password"]))); // 对密码进行加密// 5.判断执行结果if(!$pre02->execute()){die( "注册失败<br/><a href='zhuce.html'>点击重新注册</a>");}else{echo '<div class="modal fade" id="delModal" tabindex="-1" aria-labelledby="delModalLabel" aria-hidden="true"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h5 class="modal-title" id="delModalLabel">注册成功!</h5><button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" onclick="goToLogin()"></button></div><div class="modal-body">即将进入登录页面。
- 系统首页
if($result->num_rows > 0){ // num_rows 查询的结果行数// 输出表格头部信息 echo "<h3 class='text-light d-flex justify-content-center fs-2 bg-dark mt-3'>图书信息表</h3><table class='table table-bordered table-hover table-responsive text-nowrap'><tr class='fs-5'><th class='text-primary'>图书编号</th><th class='text-primary'>书名</th><th class='text-primary'>作者</th><th class='text-primary'>出版社</th><th class='text-primary'>页码</th><th class='text-primary'>数量</th><th class='de d-flex justify-content-center text-primary'>操作</th></tr>";while($row = $result->fetch_assoc()){ // fetch_assoc()从结果集中取得一行作为关联数组echo "<tr><td class='text-secondary fs-5'>{$row['book_id']}</td><td class='text-secondary fs-5'>{$row['book_name']}</td><td class='text-secondary fs-5'>{$row['author']}</td><td class='text-secondary fs-5'>{$row['publisher']}</td><td class='text-secondary fs-5'>{$row['page']}</td><td class='text-secondary fs-5'>{$row['number']}</td><td class='d-flex justify-content-center'><a href='operate.php?action=delete&id={$row['book_id']}'><button class='btn btn-danger' onclick='javascript:return del()'>删除</button></a>  <a href='update.php?id={$row['book_id']}'><button class='btn btn-primary'>修改</button></a>
- 添加图书
$sql01="select book_name from book_info where book_name = ? "; // 1.1.定义sql--查询$pre01 = $conn->prepare($sql01); // 1.2.执行预处理,获取预处理结果对象$pre01->bind_param("s",$book_name); // 1.3.将字段与预处理绑定。$uname指向sql语句里面的'?'。$book_name = $_POST["bookname"]; // 1.4.为参数赋值:用户名来源于注册页面的用户输入信息$pre01->execute(); // 1.5 执行查询if($pre01->fetch()){ // 1.6判断执行结果,fetch()获取查询到的数据,如果有值就提示重名die( "该书名已被占用,请重新录入<br/><a href='add.html'>点击重新录入</a>");}else{// 1.定义sql--添加$sql02="insert into book_info (book_id, book_name, author, publisher, page, number) values (null, ?, ?, ?, ?, ?)";// 2.执行预处理,获取预处理结果对象$pre02 = $conn->prepare($sql02);// 3.将字段与预处理绑定$pre02->bind_param("sssii", $book_name, $author, $publisher, $page, $number); // s:string i:int// 4.为参数赋值:用户,密码$book_name = $_POST["bookname"];$author = $_POST["author"];$publisher = $_POST["publisher"];$page = @$_POST["page"]; $number = $_POST["number"];// 5.判断执行结果if(!$pre02->execute()){die( "<script>alert('添加成功!');window.location.href='add.html';</script>");}else{echo "<script>alert('添加成功!');window.location.href='index.php';</script>";}
- 修改图书
<?phpinclude "conn.php";$sql="select * from book_info where book_id = ?"; $pre = $conn->prepare($sql);$pre->bind_param("i",$book_id);$book_id = $_GET['id'];$pre->bind_result($book_id, $book_name, $author, $publisher, $page, $number);$pre->execute(); $pre->fetch(); ?>
- 文件目录
演示视频