Design and Implementation of Online Bookstore Based on PHP

About the author: a full-stack development project, engaged in the development and research of Java, Python, front-end, and small programs, interested in big data applications and development,

Main content: Java project, front-end project, Python project, small program development, big data project, microcontroller

Favorites, likes, don't get lost, it's good to follow the author

Get the source code at the end of the article 

Thank you for your attention, please bookmark to avoid forgetting, like to show encouragement, comment to give suggestions, love you

Item number: BS-PHP-001

1. Environmental introduction

Locale: PHP

Database: Mysql: mysql5.7

Application server: APACHE

Development tools: IDEA or others

2. Project introduction

2.1 Purpose and significance

This online bookstore is aimed at the actual needs of the current online bookstore, starting from the actual work, analyzing the problems existing in the past online bookstore, combining the structure, concept, model, principle, and method of the computer system, under the circumstances of various advantages of the computer , with the help of php programming language, php technology, mysql database and apache server to complete all the functions of the system. This online bookstore mainly includes multiple modules such as system user management module, news article management module, book information management, shopping mall order management, login module, and exit module. It helps the online bookstore to achieve informatization and networking. Through the test, the system design goal is realized. Compared with the traditional management mode, this system makes reasonable use of the data resources of the online bookstore, effectively reduces the economic investment of the online bookstore, and greatly Improve the efficiency of the online bookstore.

With the rapid development of modern online bookstores, it can be said that online bookstores have gradually become one of the most important parts of the process of modern online bookstores. However, the traditional online bookstores in our country have not established a complete and effective online bookstore for a long time. The traditional online bookstores have been unable to adapt to the rapid development. Both in terms of efficiency and effect, they are far from the expectations. , It can be asserted that the traditional online bookstore model is no longer suitable, and has even dragged down the development. Therefore, a convenient and efficient management system is needed.

The main significance of the system design is that, on the one hand, for the website, the system can bring great convenience after the system goes online. The online bookstore belongs to a very meticulous management mode, which requires a large amount of data. Computer management can improve the accuracy and make it easier What is convenient is the query of information, which greatly improves work efficiency and management quality; on the other hand, through the design of the system, I have a deeper understanding of software design, and have a strong interest in learning. There is a unique way of analysis, which is a good opportunity to exercise before entering the society [3][4].

Aiming at the existing problems and needs, through the analysis of functional requirements, a digital and information-based online bookstore is specially established.

2.2 Function introduction

This system mainly includes multiple functional modules such as system user management, news article management, book information management, and book category management. The requirements of these functional modules are briefly described below.

Administrator's login module: The administrator logs in to the system to manage other management modules of the system.

User login module: users log in to the system, inquire about personal information, etc., and operate available functions.

User registration module: Tourist users can register as users, and the system will feedback whether the registration is successful.

Add administrator module: Add more administrators to the system, administrators include ordinary administrators and super administrators.

News article management module:

News article list: present the news article table of the database to the administrator in the form of a list.

Add news articles: implement administrators to add news articles.

Modify news articles: implement administrators to modify news articles.

Message management module:

Add message: implement the administrator to add a message, which should include a message.

Modify message: realize the administrator to modify the message, including modifying the message.

Book information management module:

Book information list: display the book information list.

Book category management module:

Book category list: display all book categories in the system, which can be queried by keywords.

Book Category Deletion: Delete wrongly entered or expired book categories.

User module:

Data management: users log in to the system. You can view your own personal homepage.

System Information: Users can view their own system prompt information.

Modify information: users can modify their own account password.

Information search: Users can search for information in the site through keywords.

Password modification: Users can modify their personal login passwords.

System management module: including data backup.

Exit module:

Admin logout: used by the administrator to log out of the system.

User Logout: Used by users to log out of the system.

2.3 Overall Design

Overall business process: Enter the account number and password on the login page as a user, and log in to the system home page after the database authentication is successful. You can use the system, management system and other functions to operate, and enter the account number and password on the login page as an administrator , after database authentication, after successful authentication, you can log in to the system home page, and you can use the system, management system and other functions to operate.

The business process of the system is shown in the figure below.

Figure 1 System business flow chart

The system is mainly divided into administrator-side design and user-side design. The user-side module is mainly for ordinary users in the system to see their basic information and maintain their own information when they register and log in to the system; Add and delete, users in the system can be managed.

The functional structure diagram of the system is shown in the figure below.

  1. Registration module: Tourist users can perform account registration in the system. The data that needs to be input for account registration include user name, password, confirmation password, email, qq, etc. After submitting the registration information, the system judges whether the registration data entered by the user meets the specifications through the js code , if it meets the specifications, add a new user record in the system database, for security, use the md5 encryption algorithm to complete the encryption of the password, and then store it in the database.
  2. Login module: During the user login process, it includes user name, password and verification code. The system needs to judge whether the verification code is correct or not. To enter a verification code. After judging that the verification code is correct, judge the user name and password. Since the user password is encrypted with MD5, when judging the user password, the password should be converted to MD5 before judging. When the user name or password is incorrect , returns to the login page and displays an error message.
  3. News article management module: design the news article table of the system, and the administrator manages the news article data, such as adding, deleting, modifying, querying, etc. When the administrator adds a news article, after entering the news article, use the js function to judge whether the input format is Correct, after the judgment is correct, insert the news article data into the news article table.
  4. Book category management module: design the book category table of the system, and the administrator manages the book category data, such as adding, deleting, modifying, querying, etc. When the administrator adds a book category, after entering the book category, use the js function to judge whether the input format is Correct, after the judgment is correct, insert the book category data into the book category table.
  5. Message management module: design the message information table of the system, and the administrator manages the message data, such as adding, deleting, modifying, querying, etc. When the administrator adds a message, after entering the message information, use the js function to judge whether the input format is correct, judge After it is correct, insert the message data into the message information table.
  6. Book information management module: The book information management module includes book information entry, book information list, book information search, book information modification, and book information deletion, all of which implement database operations through sql statements and place the data in the html interface.
  7. System management module: data backup function

2.4 Database design

1. Establish the database plan that best meets the customer's needs.

2. Standardize the database to avoid unnecessary errors.

3. Database Integrity.

4. Permission requirements for each user.

5. The performance requirements of the application program, when designing the database, each function in mysql must be used to maintain the operation.

6. Regular database maintenance.

Create a database named phpwssdhsg5043a779 on the server, including the following tables:

allusers table:

serial number

Field Name

Field Type

size

Allow empty

The maximum length

Remark

1

id

Int

4

10

2

username

150

255

3

pwd

150

255

4

cx

150

255

5

addtime

DateTime

8

19

dingdan table:

serial number

Field Name

Field Type

size

Allow empty

The maximum length

Remark

1

id

Int

4

10

2

dingdanhao

150

255

3

other

150

255

4

dingdanneirong

1073741823

255

5

yonghuming

150

255

6

xingming

150

255

7

youjidizhi

1073741823

255

8

youbian

150

255

9

dianhua

150

255

10

kuaidileixing

150

255

11

kuaidifeiyong

150

255

12

addtime

DateTime

8

19

13

ISI

1073741823

255

14

isf

6

255

dx table:

serial number

Field Name

Field Type

size

Allow empty

The maximum length

Remark

1

ID

Int

4

10

2

leibie

1073741823

255

3

content

1073741823

255

4

addtime

DateTime

8

19

goumaijilu list:

serial number

Field Name

Field Type

size

Allow empty

The maximum length

Remark

1

id

Int

4

10

2

shangpinbianhao

150

255

3

shangpinmingcheng

150

255

4

shangpinleibie

150

255

5

jiage

150

255

6

shuliang

150

255

7

other

150

255

8

beizhu

1073741823

255

9

goumairen

150

255

10

ISI

30

255

11

addtime

DateTime

8

19

liuyanban table:

serial number

Field Name

Field Type

size

Allow empty

The maximum length

Remark

1

id

Int

4

10

2

zhanghao

150

255

3

zhaopian

150

255

4

xingming

150

255

5

liuyan

150

255

6

addtime

DateTime

8

19

7

huifu

150

255

pinglun table:

serial number

Field Name

Field Type

size

Allow empty

The maximum length

Remark

1

ID

Int

4

10

2

wenzhangID

1073741823

255

3

pinglunneirong

1073741823

255

4

pinglunren

1073741823

255

5

addtime

DateTime

8

19

6

biao

150

255

7

pingfen

Int

4

10

shangpinleibie form:

serial number

Field Name

Field Type

size

Allow empty

The maximum length

Remark

1

id

Int

4

10

2

shangpinleibie

150

255

3

addtime

DateTime

8

19

shangpinxinxi form:

serial number

Field Name

Field Type

size

Allow empty

The maximum length

Remark

1

id

Int

4

10

2

shangpinbianhao

150

255

3

shangpinmingcheng

150

255

4

shangpinleibie

150

255

5

zhutu

150

255

6

xiangqingmiaoshu

1073741823

255

7

jiage

150

255

8

Xiaoliang

Float

8

15

9

pingfen

Float

8

15

10

kucun

150

255

11

faburen

150

255

12

issh

30

255

13

addtime

DateTime

8

19

shoucangjilu表:

序号

字段名称

字段类型

大小

允许为空

最大长度

备注

1

ID

Int

4

10

2

username

1073741823

255

3

xwid

1073741823

255

4

biao

1073741823

255

5

addtime

DateTime

8

19

6

ziduan

1073741823

255

xinwentongzhi表:

序号

字段名称

字段类型

大小

允许为空

最大长度

备注

1

id

Int

4

10

2

biaoti

1073741823

255

3

leibie

150

255

4

neirong

1073741823

255

5

tianjiaren

150

255

6

addtime

DateTime

8

19

7

shouyetupian

150

255

8

dianjilv

Int

4

10

9

zhaiyao

1073741823

255

yonghuzhuce表:

序号

字段名称

字段类型

大小

允许为空

最大长度

备注

1

id

Int

4

10

2

zhanghao

150

255

3

mima

150

255

4

xingming

150

255

5

xingbie

150

255

6

diqu

150

255

7

Email

150

255

8

zhaopian

150

255

9

addtime

DateTime

8

19

10

issh

30

255

11

shouji

1073741823

255

youqinglianjie表:

序号

字段名称

字段类型

大小

允许为空

最大长度

备注

1

id

Int

4

10

2

wangzhanmingcheng

150

255

3

wangzhi

150

255

4

addtime

DateTime

8

19

5

logo

1073741823

255

三,系统展示

系统首页:

在系统的前台首页,主要有用户登录页面,以及相关新闻的展示等,在首页的导航栏中可看出,该系统主要有网站首页、用户注册、图书信息、系统简介、新闻资讯等主要模块。

为了确保系统安全性,系统操作员只有在后台登录界面输入正确的用户名、密码、权限以及验证码,单击“登录”按钮后才能够进入本系统的后台管理界面。

用户登录流程图如下所示。

 在线留言

用户点击在线留言,提交信息,添加成功信息后,用户管理留言信息,审核留言信息。

留言管理流程图如下所示。

 在线购物

 用户管理

系统用户管理主要是对新用户的添加和旧用户的删除。新用户的添加主要是指添加用户名称并确定其密码;旧用户的删除也是从下拉菜单中找到对应的用户名称将其删除。不论是新用户添加还是旧用户的删除,这个权限只有管理员具有。

新闻管理

新闻文章信息添加功能主要指对其标题、内容等一些基本信息的添加、删除和修改。新闻文章查询能根据标题、内容等多种条件对新闻文章信息进行查询。

 

图书管理

管理员发布新的图书信息,系统显示图书信息,图书信息添加功能主要指对其编号、姓名等一些基本信息的添加、删除和修改。

 

四,核心代码展示

<?php
session_start();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>临时离开</title> 
<style type="text/css">
<!--
body {
	background-color: #999999;
}
-->
</style></head> 
<body> 



	
<script language="javascript"> 


function sAlert() 
{ 

document.onkeydown = function(){
          if(event.keyCode==116) {
          event.keyCode=0;
          event.returnValue = false;
          }
     }
    
document.oncontextmenu = function() {event.returnValue = false;}
var msgw,msgh,bordercolor; 
msgw=400;//提示窗口的宽度 
msgh=100;//提示窗口的高度 
titleheight=25 //提示窗口标题高度 
bordercolor="#336699";//提示窗口的边框颜色 
titlecolor="#99CCFF";//提示窗口的标题颜色 
var sWidth,sHeight; 
sWidth=document.body.offsetWidth;//获取窗口宽度 
sHeight=screen.height;//获取屏幕高度 
var bgObj=document.createElement("div");//关键在这里,原理:在body中创建一个div,并将其宽度与高度设置为覆盖整个窗体,如此一来就无法对其它窗口时行操作 
bgObj.setAttribute('id','bgDiv'); 
bgObj.style.position="absolute"; 
bgObj.style.top="0"; 
bgObj.style.background="#777"; 
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; 
bgObj.style.opacity="0.6"; 
bgObj.style.left="0"; 
bgObj.style.width=sWidth + "px"; 
bgObj.style.height=sHeight + "px"; 
bgObj.style.zIndex = "10000"; 
document.body.appendChild(bgObj);//设置完此div后将其显示出来 
var msgObj=document.createElement('div');//创建一个消息窗口 
msgObj.setAttribute("id","msgDiv"); 
msgObj.setAttribute("align","center"); 
msgObj.style.background="white"; 
msgObj.style.border="1px solid " + bordercolor; 
msgObj.style.position = "absolute"; 
msgObj.style.left = "50%"; 
msgObj.style.top = "50%"; 
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; 
msgObj.style.marginLeft = "-225px" ; 
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px"; 
msgObj.style.width = msgw+"px"; 
msgObj.style.height = msgh+"px"; 
msgObj.style.textAlign = "center"; 
msgObj.style.lineHeight ="25px"; 
msgObj.style.zIndex = "10001"; 
var title=document.createElement("h4"); //创建一个标题,以备放置在消息层 
title.setAttribute("id","msgTitle"); 
title.setAttribute("align","right"); 
title.style.margin="0"; 
title.style.padding="3px"; 
title.style.background=bordercolor; 
title.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; 
title.style.opacity="0.75"; 
title.style.border="1px solid " + bordercolor; 
title.style.height="18px"; 
title.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; 
title.style.color="white"; 
title.style.cursor="pointer"; 
title.innerHTML=""; 
//title.onclick=function() 
//{ 
//document.body.removeChild(bgObj);//移除覆盖整个窗口的div层 
//document.getElementById("msgDiv").removeChild(title);//移除标题 
//document.body.removeChild(msgObj);//移除消息层 
//} 
document.body.appendChild(msgObj); 
document.getElementById("msgDiv").appendChild(title); 
var txt=document.createElement("p"); 
txt.style.margin="1em 0" 
txt.setAttribute("id","msgTxt"); 
txt.innerHTML="<form action='jiesuo.php' method='post'><table><tr><td align=center>请输入您的密码:<input type='text' name='suopinmima'><input type='submit' name'Submit' value='解锁' /></td></tr></table></form>"; 
document.getElementById("msgDiv").appendChild(txt); 
} 
</script> 
<?php
if($_GET["js"]=="1")
{
	?>
		<script language="javascript"> 
		location.href='main.php';
	</script>
	<?php
	}
else
{
?>
	<script language="javascript"> 
sAlert();
	</script>
	<?php
}
	?>
</body> 
</html> 
<?php 
$id=$_GET["id"];
include_once 'conn.php';

$ndate =date("Y-m-d");
$addnew=$_POST["addnew"];
if ($addnew=="1" )
{
	$biaoti=$_POST["biaoti"];$leibie=$_POST["leibie"];$neirong=$_POST["neirong"];$shouyetupian=$_POST["shouyetupian"];$dianjilv=$_POST["dianjilv"];$tianjiaren=$_POST["tianjiaren"];
	$sql="update xinwentongzhi set biaoti='$biaoti',leibie='$leibie',neirong='$neirong',shouyetupian='$shouyetupian',dianjilv='$dianjilv',tianjiaren='$tianjiaren' where id= ".$id;
	mysql_query($sql);
	echo "<script>javascript:alert('修改成功!');</script>";
}

$sql="select * from xinwentongzhi where id=".$id;
$query=mysql_query($sql);
$rowscount=mysql_num_rows($query);
if($rowscount>0)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>修改<?php echo mysql_result($query,$i,leibie);?></title>
<link rel="stylesheet" href="kindeditor-4.1.10/themes/default/default.css" />
	<link rel="stylesheet" href="kindeditor-4.1.10/plugins/code/prettify.css" />
	<script charset="utf-8" src="kindeditor-4.1.10/kindeditor.js"></script>
	<script charset="utf-8" src="kindeditor-4.1.10/lang/zh_CN.js"></script>
	<script charset="utf-8" src="kindeditor-4.1.10/plugins/code/prettify.js"></script>
	<script>
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="neirong"]', {
				cssPath : 'kindeditor-4.1.10/plugins/code/prettify.css',
				uploadJson : 'kindeditor-4.1.10/php/upload_json.php',
				fileManagerJson : 'kindeditor-4.1.10/php/file_manager_json.php',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						K('form[name=example]')[0].submit();
					});
				}
			});
			prettyPrint();
		});
	</script>
<link rel="stylesheet" href="css.css" type="text/css"><script language="javascript" src="js/hsgrili.js"></script>
</head>
<script language="javascript">
function OpenScript(url,width,height)
{
  var win = window.open(url,"SelectToSort",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
function OpenDialog(sURL, iWidth, iHeight)
{
   var oDialog = window.open(sURL, "_EditorDialog", "width=" + iWidth.toString() + ",height=" + iHeight.toString() + ",resizable=no,left=0,top=0,scrollbars=no,status=no,titlebar=no,toolbar=no,menubar=no,location=no");
   oDialog.focus();
}
</script>
<body>
<p>修改<?php echo mysql_result($query,$i,leibie);?>: 当前日期: <?php echo $ndate; ?></p>

<form id="form1" name="form1" method="post" action="">
<table width="100%" border="1" align="center" cellpadding="3" cellspacing="1" bordercolor="#00FFFF" style="border-collapse:collapse"> 
      <tr><td>标题:</td><td><input name='biaoti' type='text' id='biaoti' size='50' value='<?php echo mysql_result($query,$i,biaoti);?>' /></td></tr><tr><td>类别:</td><td><input name='leibie' type='text' id='leibie' value='<?php echo mysql_result($query,$i,leibie);?>' /></td></tr><tr><td>内容:</td><td><textarea name="neirong" style="width:700px;height:200px;visibility:hidden;"><?php echo mysql_result($query,$i,neirong);?></textarea></td>
      </tr><tr><td>首页图片:</td><td><input name='shouyetupian' type='text' id='shouyetupian' size='50'  value='<?php echo mysql_result($query,$i,shouyetupian);?>' /> &nbsp;<a href="javaScript:OpenScript('upfile.php?Result=shouyetupian',460,180)"><img src="Images/Upload.gif" width="30" height="16" border="0" align="absmiddle" /></a></td></tr><tr><td>点击率:</td><td><input name='dianjilv' type='text' id='dianjilv' value='<?php echo mysql_result($query,$i,dianjilv);?>' /></td></tr><tr><td>添加人:</td><td><input name='tianjiaren' type='text' id='tianjiaren' value='<?php echo mysql_result($query,$i,tianjiaren);?>' /></td></tr>
    <tr>
      <td>&nbsp;</td>
      <td><input name="addnew" type="hidden" id="addnew" value="1" />
      <input type="submit" name="Submit" value="修改" />
      <input type="reset" name="Submit2" value="重置" /></td>
    </tr>
  </table>
</form>
<?php
	}
?>
</body>
</html>

五,项目总结

经过几个月的努力还坚持,网上书店终于完成了,程序功能模块能按照需求来运行,能实现多用户的迸发使用,但是系统由于设计经验以及专业知识的局限性,在本系统的开发过程中,在一些功能方面和业务逻辑方面做得不是很完善,系统还存在一些缺陷。界面的设计从布局到外观,受限于自身的设计功底较低,没能达到自己所要设计的界面要求,另一方面,系统存在一些没有考虑的问题和模块。

在学习的过程中首次进行独立设计工作,编码过程出现了许多问题和困难,原以为正确无误的程序运行过程中不会遇到问题,但是在运行过程中也总会出现各种各样的问题,在调试过程中找不出运行出错的原因。而这些基本问题却都是一些简单的问题,例如标点符号应该是英文状态下的,却因为不好的编程习惯造成了一些中文的符号输入,经过仔细观察和老师的帮组下,还是将问题解决了。

目前系统的功能比较简单,还存在许多瑕疵,这是一份遗憾,也是促进我不断进步的动力。

Guess you like

Origin blog.csdn.net/znzbs/article/details/131614499