当前位置:网站首页>Library management system (PHP final report)

Library management system (PHP final report)

2022-06-22 02:55:00 m0_ fifty-four million eight hundred and fifty-three thousand f

List of articles

I. project overview

Two Library management system description

2.1 Introduction to the project

2.2 Module introduction

2.3? Database structure design

3、 ... and Detailed design of main modules

3.1 Description of main technical points

3.2 Result display

Summary and reflection



I. project overview

Get into 21 Since the 20th century , Information technology has fundamentally promoted the rapid development of libraries , Computers and computer management systems have become the main equipment and systems for library management . At present, many large-scale libraries have a set of relatively perfect management systems , But in some small and Medium-sized Libraries , Most of the work still needs to be done manually , The work efficiency is relatively low , It is not convenient for dynamic 、 Adjust the structure of books in time . In order to better meet the management needs of the current library , Solve the malpractice of manual management , More and more small and medium-sized libraries are gradually changing to computer information management . The university has a small library , Provide a reading for the whole school 、 Space for learning . In recent years , As the source of students continues to expand , The scale of the library has also expanded , The number of books has correspondingly increased , Information about books has multiplied . Faced with such a huge amount of information , The school leaders decided to use a set of reasonable 、 It works 、 standard 、 A practical library management system , Unify the books and materials in the school 、 Centralized management . With the development of modernization , Develop a library management system , Its development aim is to realize the systematization of library management 、 Standardization and Automation , Achieve a collection of books and materials 、 The goal of unified management . therefore , The purpose of this project is to develop a library management system for colleges and universities .

The library management system is based on PHP Framework system . It is used to quickly build system applications in a short time . The whole system can be roughly divided into five modules , Namely **** Login module 、 Book management 、 User management 、 Borrowing management ********、**** Personal information module . Combined with the teacher's classroom explanation , The system will be further improved .

The main problem to be solved in this project is how to design a practical system to realize some book management functions for colleges and universities through our knowledge . This software development The tool is Eclipse, Server is Xampps********, The background database adopts mysql********. The purpose of this semester requires that we have Skilled PHP framework Knowledge and ********HTML frame , We should also have the ability to supplement and improve the system by searching for information .


Tips : The following is the main body of this article , The following cases can be used for reference

Two Library management system description

2.1 Introduction to the project

This system is mainly used in some university libraries , The overall task is to realize some basic functions of borrowing college students' books , Such as using the query of book information 、 modify 、 increase 、 Delete and other basic functions .

This system mainly realizes the login 、 Book information display 、 User management 、 The borrowing of books, etc . Its main functions are :

  1. Login function : By entering a different account number 、 Password and verification code enter the management interface with different permissions , You can also add users through the administrator to achieve account registration .
  2. Personal center function : This function is developed for users to view their personal information , Including viewing user information , Such as name 、 Class, etc , And realize the function of personal password modification .
  3. Book information display function : This function is an important function of the platform , Including details of book information , Such as book title 、 author 、 Book number 、 Price 、 Book introduction, etc , This information can be updated .
  4. User management functions : This function is mainly set for administrators , The user's personal information can be 、 Modify and query the account status and other information .

The borrowing function of books : This function is mainly set for administrators , It can realize the functions of borrowing and returning books to users .

2.2 modular ******** brief introduction

chart 1 Library management system module diagram

The system is divided into five modules , It is divided into login module 、 Personal center 、 Book management 、 User management 、 Book borrowing module .

2.3 Database structure design ****

The relevant information of the data table involved in the module I am responsible for is as follows :

surface 1 User login information table

Field name

data type

Field length

Field description

remarks

id

int

50

user ID

Primary key ( Non empty )

name

varchar

50

user name

pwd

varchar

50

User password

status

tinyint

3

User state

class

varchar

50

class

admin

tinyint

3

Is it an administrator

last_login_time

datetime

10

Last login time

surface 2 The book ******** Information sheet

Field name

data type

Field length

Field description

remarks

id

varchar

50

Book number

Primary key ( Non empty )

name

varchar

50

Book name

autho

varchar

50

author

press

varchar

50

Press.

press_time

varchar

50

Publication date

price

varchar

50

Price

ISBN

varchar

50

ISBN

desc

text

50

Introduction to the work

surface 3 Book borrowing ******** surface

Field name

data type

Field length

Field description

remarks

book_id

int

50

Book number

Primary key ( Non empty )

user_id

int

50

user ID

borrow_date

date

50

Borrowing date

back_date

date

50

Return date

3、 ... and Detailed design of main modules

3.1 Description of main technical points

(1) Sign in

// validate logon , Add verification code function

//Json Login interface

?public function login(){

????????header("Content-Type:application/json");



????????$rightCode ?= ??strtolower($_SESSION['verifyCode']);// Correct verification code 

????????$code ??????= ??strtolower($_POST['verify']); ??// Input verification code 

????????$userId ????= ??htmlentities($_POST['userId']); ????// account number 

????????$password ??= ??md5($_POST['password']); ???????????// password 

// Verify the verification code first , Verify the account and password correctly , Reduce database pressure

????????if($code != $rightCode){

????????????$this->sendJsonMessage(" Verification code error ",1);

????????}

// Verify account password

??$userModel = new UserModel;

????????$where = "id='{$userId}' and pwd='{$password}'";

????????$result = $userModel->fetchOne($where);

????????if(!empty($result) && $result['status'] == 1){



????????????$_SESSION['userId'] ??????????= ????$userId;

????????????$_SESSION['admin'] ???????????= ????$result['admin'];

????????????$_SESSION['last_login_time'] ?= ????$result['last_login_time'];



????????????$message = array("message"=>"OK","code"=>0,"admin"=>"{$result['admin']}");

(2) Book management

// Show book details and additions, deletions and modifications

// Get book information per page

$offset = ($currentPage - 1) * $eachPerPage;

????????$books = $bookModel->fetchAllWithJoin($where,"LIMIT {$offset},{$eachPerPage}");

// Pagination

???$pager = new Pager($currentPage,$count,$eachPerPage,"?p=Admin&c=Book&a=index",$parms);

????????

????????$this->smarty->assign("books",$books);

????????$this->smarty->assign("mode",$mode);

????????$this->smarty->assign("pageStr",$pager->page());

????????$this->smarty->display("Book/index.html");

????}

// Display the book details page

?public function detail(){

????????$this->accessPage();



????????$id = $_GET['id'];



????????$bookModel = new BookModel;

????????$result = $bookModel->fetchOneWithJoin("book_info.id={$id}");

????????

????????$this->smarty->assign("book",$result);

????????$this->smarty->display("Book/detail.html");

????}

// Show the add book page

public function add(){

????????$this->accessPage();



????????$this->smarty->display("Book/add.html");

????}

// Display the edit book page

public function edit(){

????????$this->accessPage();



????????$id = $_GET['id'];



????????$bookModel = ???new BookModel;

????????$book ?????= ???$bookModel->fetchOne("id={$id}");

????????

????????$this->smarty->assign("book",$book);

????????$this->smarty->display("Book/edit.html");

????}

//Json Add book interface

?public function insert(){

????????$this->accessJson();

????????$bookInfo['name'] ??????= ???$_POST['name'];

????????$bookInfo['author'] ????= ???$_POST['author'];

????????$bookInfo['press'] ?????= ???$_POST['press'];

????????$bookInfo['press_time'] ?= ??$_POST['pressTime'];

????????$bookInfo['price'] ?????= ???$_POST['price'];

????????$bookInfo['ISBN'] ??????= ???$_POST['ISBN'];

????????$bookInfo['desc'] ??????= ???$_POST['desc'];

// Verify that the information is complete

?if(in_array("",$bookInfo)){

????????????$this->sendJsonMessage(" Please enter the full information ",1);

????????}



????????$bookModel = new BookModel;

????????if($bookModel->insert($bookInfo)){

????????????$this->sendJsonMessage(" Add success ",0);

????????}else{

????????????$this->sendJsonMessage(" Add failure ",1);

????????}

????}

//Json Interface modification books

??public function update(){

????????$this->accessJson();

????????

????????$id ?????????????????????= ???$_POST['id'];

????????$bookInfo['name'] ???????= ???$_POST['name'];

????????$bookInfo['author'] ?????= ???$_POST['author'];

????????$bookInfo['press'] ??????= ???$_POST['press'];

????????$bookInfo['press_time'] ?= ???$_POST['press_time'];

????????$bookInfo['price'] ??????= ???$_POST['price'];

????????$bookInfo['ISBN'] ???????= ???$_POST['ISBN'];

????????$bookInfo['desc'] ???????= ???$_POST['desc'];



????????// Verify that the information is complete 

????????if(in_array("",$bookInfo)){

????????????$this->sendJsonMessage(" Please enter the full information ",1);

????????}



????????$bookModel = new BookModel;

????????if($bookModel->update($bookInfo,"id={$id}")){

????????????$this->sendJsonMessage(" Modification successful ",0);

????????}else{

????????????$this->sendJsonMessage(" Modification failed ",1);

????????}

????}

//Json Delete book interface

?public function delete(){

????????$this->accessJson();



????????$id = $_POST['id'];



????????$bookModel ??= new BookModel;

????????$borrowModel = new BorrowModel;

????????if($bookModel->delete("id={$id}") && $borrowModel->delete("book_id={$id}")){

????????????$this->sendJsonMessage(" Delete successful ",0);

????????}else{

????????????$this->sendJsonMessage(" Delete failed ",1);

????????}

????}

}

(3) User management

// Manage user information

// Get user information per page 

????????$offset = ($currentPage - 1) * $eachPerPage;

????????$users = $userModel->fetchAllUser($where,"LIMIT {$offset},{$eachPerPage}"); ???????



????????// Pagination 

????????$pager = new Pager($currentPage,$count,$eachPerPage,"?p=Admin&c=User&a=index",$parms);



????????$this->smarty->assign("users",$users);

????????$this->smarty->assign("mode",$mode);

????????$this->smarty->assign("pageStr",$pager->page());

????????$this->smarty->display("User/index.html");

????}



????// Display the add user interface 

????public function add(){

????????$this->accessPage();



????????$this->smarty->display("User/add.html");

????}



????// Display the management user interface 

????public function manage(){

????????$this->accessPage();



????????$id = $_GET['id'];



????????$userModel = new UserModel;

????????// Get user information 

????????$userInfo ?= $userModel->fetchOne("id={$id}");

????????

????????// prevent url Illegal transfer of ginseng 

????????if(empty($userInfo)){

????????????echo "<script>alert(' The user does not exist ');</script>";

????????????die();

????????}



????????$borrowModel = new BorrowModel;

????????// Get user borrowing information 

????????$borrowInfo = $borrowModel->getBorrowInfo("borrow_list.user_id={$id}");

????????

????????$this->smarty->assign("userInfo",$userInfo);

????????$this->smarty->assign("borrowInfo",$borrowInfo);

????????$this->smarty->display("User/manage.html");

????}



????//Json Add user interface 

????public function insert(){

????????$this->accessJson();



????????$user['id'] ?????= ?$_POST['userId'];

????????$user['pwd'] ????= ?md5($_POST['password']);

????????$user['name'] ???= ?$_POST['name'];

????????$user['class'] ??= ?$_POST['class'];

????????$user['status'] ?= ?$_POST['status'] ? 1 : 0;



????????$usermodel = new UserModel;



????????if(in_array("",$user)){

????????????$this->sendJsonMessage(" Please complete the information ",1);

????????}



????????if($usermodel->rowCount("id={$user['id']}")){

????????????$this->sendJsonMessage(" This user ID Already exists ",1);

????????}



????????if($usermodel->insert($user)){

????????????$this->sendJsonMessage(" Add user successfully ",0);

????????}else{

????????????$this->sendJsonMessage(" Failed to add user ",1);

????????}

????}



????//Json Modify the user interface 

????public function changeInfo(){

????????$this->accessJson();



????????$id ????????????= ?$_POST['userId'];

????????$data['name'] ??= ?$_POST['name'];

????????$data['class'] ?= ?$_POST['class'];



????????if(in_array("",$data)){

????????????$this->sendJsonMessage(" Please complete the information ",1);

????????}



????????$userModel = new UserModel;



????????if($userModel->update($data,"id={$id}")){

????????????$this->sendJsonMessage(" Modification successful ",0);

????????}else{

????????????$this->sendJsonMessage(" Modification failed ",1);

????????}

????}



????//Json Loss reporting user interface 

????public function lost(){

????????$this->accessJson();



????????$id ?= ?$_POST['userId'];



????????$userModel = new UserModel;

????????if($userModel->update(array("status"=>0),"id={$id}")){

????????????$this->sendJsonMessage(" Report the loss successfully ",0);

????????}else{

????????????$this->sendJsonMessage(" Loss reporting failed ",1);

????????}

????}



????//Json Enable user interface 

????public function open(){

????????$this->accessJson();



????????$id ?= ?$_POST['userId'];



????????$userModel = new UserModel;

????????if($userModel->update(array("status"=>1),"id={$id}")){

????????????$this->sendJsonMessage(" Enabled successfully ",0);

????????}else{

????????????$this->sendJsonMessage(" Enable failed ",1);

????????}

????}



????//Json Modify the user password interface 

????public function changePwd(){

????????$this->accessJson();



????????if(!$_POST['pwd']){

????????????$this->sendJsonMessage(" Please input a password ",1);

????????}



????????$id ??= $_POST['userId'];

????????$pwd ?= md5($_POST['pwd']);



????????$userModel = new UserModel;

????????if($userModel->update(array("pwd"=>$pwd),"id={$id}")){

????????????$this->sendJsonMessage(" Modification successful ",0);

????????}else{

????????????$this->sendJsonMessage(" Modification failed ",1);

????????}

????}



????//Json Delete user interface 

????public function delete(){

????????$this->accessJson();



????????$id ?= ?$_POST['userId'];



????????$userModel ??= new UserModel;

????????$borrowModel = new BorrowModel;

????????if($userModel->delete("id={$id}") && $borrowModel->delete("user_id={$id}")){

????????????$this->sendJsonMessage(" Delete successful ",0);

????????}else{

????????????$this->sendJsonMessage(" Delete failed ",1);

????????}

}

(4) Borrowing management

// Complete the end return of the user

//Json Borrowing and returning interface 

????public function manage(){

????????$this->accessJson();



????????$bookId ?= ?$_POST['bookId'];

????????$userId ?= ?$_POST['userId'];

????????$action ?= ?$_POST['action'];



????????if($userId == "" || $bookId == ""){

????????????$this->sendJsonMessage(" Please complete the information ",1);

????????}



????????$borrowModel = new BorrowModel;

????????if($action == "borrow"){

????????????// Borrow books 

????????????if($borrowModel->canBorrow($bookId,$userId)){

????????????????$data = array(

????????????????????"book_id" ????=> ?$bookId,

????????????????????"user_id" ????=> ?$userId,

????????????????????"borrow_date" => ?date("Y-m-d"),

????????????????????"back_date" ??=> ?date("Y-m-d",strtotime("+2 month"))

????????????????);

????????????????if($borrowModel->insert($data)){

????????????????????$this->sendJsonMessage(" Borrow books successfully ",0);

????????????????}else{

????????????????????$this->sendJsonMessage(" Failed to borrow a Book ",1);

????????????????}

????????????}else{

????????????????$this->sendJsonMessage(" Wrong information or the book has been lent ",1);

????????????}

????????}else if($action == "return"){

????????????// Return books 

????????????if($borrowModel->canReturn($bookId,$userId)){

????????????????if($borrowModel->delete("book_id={$bookId} AND user_id={$userId}")){

????????????????????$this->sendJsonMessage(" Return the book successfully ",0);

????????????????}else{

????????????????????$this->sendJsonMessage(" Failed to return the book ",1);

????????????????}

????????????}else{

????????????????$this->sendJsonMessage(" The information is wrong or the user does not take this book ",1);

????????????}

????????}else{

????????????$this->sendJsonMessage(" Parameter error ",1);

????????}

????}



????//Json Renewal interface 

????public function prolong(){

????????$this->accessJson();



????????// No parameter transfer interrupt 

????????if(!isset($_POST['bookId']) || !isset($_POST['userId'])){

????????????$this->sendJsonMessage(" Lack of parameter ",1);

????????}



????????$bookId = $_POST['bookId'];

????????$userId = $_POST['userId'];



????????$borrowModel = new BorrowModel;

????????$result = $borrowModel->fetchOne("book_id={$bookId} AND user_id={$userId}");



????????// You can't renew a book without borrowing it 

????????if(empty($result)){

????????????$this->sendJsonMessage(" The user did not borrow this book ",1);

????????}

????????// You can't renew it 

????????if(strtotime($result['back_date']) < time()){

????????????$this->sendJsonMessage(" Overdue books cannot be renewed ",1);

????????}



????????// Calculate the due time 

????????$backTime = date("Y-m-d",strtotime("+1 month",strtotime($result['back_date'])));

????????$data = array("back_date"=>$backTime);

????????if($borrowModel->update($data,"book_id={$bookId} AND user_id={$userId}")){

????????????$this->sendJsonMessage(" Renewal succeeded ",0);

????????}else{

????????????$this->sendJsonMessage(" Renewal failed ",1);

????????}

????}



????//Json Book Return Interface 

????public function returnBook(){

????????$this->accessJson();



????????$bookId = $_POST['bookId'];

????????$userId = $_POST['userId'];



????????$borrowModel = new BorrowModel;

????????if($borrowModel->canReturn($bookId,$userId)){

????????????if($borrowModel->delete("book_id={$bookId} AND user_id={$userId}")){

????????????????$this->sendJsonMessage(" Return the book successfully ",0);

????????????}else{

????????????????$this->sendJsonMessage(" Failed to return the book ",1);

????????????}

????????}else{

????????????$this->sendJsonMessage(" The information is wrong or the user does not take this book ",1);

????????}

}

3.2 Result display

Summary and reflection

As the relevant knowledge of this project has been emphasized many times in the class , The teacher spoke very well , Very serious , But the time to do the project is short , In this development “ The book management system ” Not completely finished , But after the group learning project, I learned to use PHP The process of developing web pages , And familiar with Eclipse Some operating procedures of this software , And for HTML And the use of databases , And some framework calls have been greatly improved , Compared with the previous web Web development , The content and professionalism of this project have been improved , And it is relatively simple and convenient

.

原网站

版权声明
本文为[m0_ fifty-four million eight hundred and fifty-three thousand f]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220253583910.html