基于Jquery和php的超市销售系统的设计与实现_第1页
基于Jquery和php的超市销售系统的设计与实现_第2页
基于Jquery和php的超市销售系统的设计与实现_第3页
基于Jquery和php的超市销售系统的设计与实现_第4页
基于Jquery和php的超市销售系统的设计与实现_第5页
已阅读5页,还剩33页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

题目基于jquery和php的超市销售系统的设计与实现系别数学与信息工程系专业年级计算机科学与技术2012级(移动互联网专业)第1章概论1.1Jquery和php简介JQuery是继prototype之后又一个优秀的Javascript库。它是轻量级的js库,它兼容css3,还兼容各种浏览器(IE6.0+,FF1.5+,safria2.0+,opera9.0+),jQuery2.0及后续版本将不再支持IE6/7/8浏览器。jQuery使用户能更方便地处理HTML(标准通用标记下的一个应用)、events、实现动画效果,并且方便地为网站提供AJAX交互。jQuery还有一个比较大的优势是,它的文档说明很全,而且各种应用也说得很详细,同时还有许多成熟的插件可供选择。jQuery能够使用户的html页面保持代码和html内容分离,也就是说,不用再在html里面插入一堆js来调用命令了,只需要定义id即可。jQuery是一个兼容多浏览器的javascript库,核心理念是writeless,domore(写得更少,做得更多)。jQuery在2006年1月由美国人johnresig在纽约的barcamp发布,吸引了来自世界各地的众多JavaScript高手加入,由DaveMethvin率领团队进行开发。如今,jQuery已经成为最流行的javascript库,在世界前10000个访问最多的网站中,有超过55%在使用jQuery。jQuery是免费、开源的,使用MIT许可协议。jQuery的语法设计可以使开发更加便捷,例如操作文档对象、选择DOM元素、制作动画效果、事件处理、使用Ajax以及其他功能。除此以外,jQuery提供API让开发者编写插件。其模块化的使用方式使开发者可以很轻松的开发出功能强大的静态或动态网页。PHP(外文名:PHP:HypertextPreprocessor,中文名:“\t"/subview/99/_blank"超文本\t"/subview/99/_blank"预处理器”)是一种通用\t"/subview/99/_blank"开源\t"/subview/99/_blank"脚本语言。\t"/subview/99/_blank"语法吸收了\t"/subview/99/_blank"C语言、\t"/subview/99/_blank"Java和\t"/subview/99/_blank"Perl的特点,利于学习,使用\t"/subview/99/_blank"广泛,主要适用于\t"/subview/99/_blank"Web开发领域。PHP独特的\t"/subview/99/_blank"语法混合了\t"/subview/99/_blank"C、\t"/subview/99/_blank"Java、\t"/subview/99/_blank"Perl以及\t"/subview/99/_blank"PHP自创的语法。它可以比\t"/subview/99/_blank"CGI或者\t"/subview/99/_blank"Perl更快速地执行\t"/subview/99/_blank"动态网页。用PHP做出的\t"/subview/99/_blank"动态页面与其他的\t"/subview/99/_blank"编程语言相比,\t"/subview/99/_blank"PHP是将\t"/subview/99/_blank"程序嵌入到\t"/subview/99/_blank"HTML(\t"/subview/99/_blank"标准通用标记语言下的一个应用)文档中去执行,执行效率比完全生成\t"/subview/99/_blank"HTML标记的\t"/subview/99/_blank"CGI要高许多;PHP还可以执行\t"/subview/99/_blank"编译后代码,编译可以达到\t"/subview/99/_blank"加密和\t"/subview/99/_blank"优化代码运行,使代码运行更快。第2章超市销售系统分析2.1网站功能概述超市销售系统为了方便使用和管理者,具有以下功能:1、将电脑调到合适分辨率,运行火狐浏览器,输入网站,打开网址2、新用户首次使用网站,如果只使用浏览功能,则无需注册,如需使用具体功能则需按照提示操作进行注册,并且依照不同权限,将用户于管理员分类3、普通用户登录后,可查看,浏览和购买商品。4、管理用户登录可以进行商品添加减少,以及价格修改等一系列操作5、购买成功后,商品会依照地址当天或者隔天由小区就近地址发货2.2用户需求系统主要是为了方便生活节奏比较快的用户,其功能一定要简单,易操作,能够快速的购买商品,并且能相对准确快速的得到商品信息,实现商品购物车添加以及购买等超市购物系统总体设计总体设计也称概要设计,在这个阶段将划分出组成网站的元素:网站素材、网站素材配置文件、网站配置,的总体结构等等。确定网站由哪些模块组成,并且网站各个模块之间的关系[8]。3.1购物网站业务流程根据用户需求以及具有类似功能的网站分析,最后得出以下网站业务流程。普通网民浏览,用户注册,登陆,获得购物或者管理权限。普通用户:分类浏览网站,获得通知,搜索需要购买物品,将物品添加至购物车,完成物品购买后,付款,物品将按照地址配送。管理者:以管理者用户进行登陆,进行物品管理,以及物品更改,价格更改,或者用户权限更改。3.2超市销售系统功能模块结构图依据需求分析阶段得到的用户需求,在保证系统基本功能要求的前提下,结合销售业务流程确定系统必须具备的所有功能,总体为以下模块图:网站基本功能与实体超市类似,其优点是利用网络虚拟空间代替部分实体超市购物空间以及功能,实现更快的响应,更小的面积占用,只需要进行简单的用户注册登录,就可以类似于其他电商平台进行所需商品购买3.3数据库功能设计针对销售系统功能设计如下数据库:用户:普通用户为2,管理用户设定为1,不同权限账户登录订单:用户将物品添加至订单销售:显示已销售物品,数量等物品类型:进行物品类型管理物品基库:储存物品总体数量第4章网站设计4.1网站概要说明本程序是在dreamwear环境下编写的网站,网站运用了mysql数据库进行数据存储,利用easyui里的jquery(javascript的类库)和html进行网站前端开发,利用php实现手误以及管理交互4.2搭载开发环境1、安装myql安装mysql进行数据存储安装phpmyadmin进行数据库的可视化操作安装dreamweaver进行php以及html编写配置easyui配置easyui框架,方便各个功能管理4.3主要功能署名整个网站主要分为以下几个模块,网站环境配置,登陆,注册,购物车添加,分页浏览4.3.1数据库连接配置:利用php语言验证数据库用户名,密码,链接数据库。<?php$db_host="localhost";$db_user="root";$db_pass="root";$db_name="shopping";$table_user="user";$table_type="type";$table_thing="thing";$table_order="order";$table_sale="sale";$link=mysql_connect($db_host,$db_user,$db_pass);mysql_select_db($db_name,$link);?>4.3.2网站安装<?phperror_reporting(0);echo"<html>";echo"<head>";echo"<title>安装程序</title>";echo"</head>";echo"<body>";echo"<LINKhref=\"style.css\"rel=stylesheet>";if(!$_POST['admin']){ echo"<scriptlanguage=\"javasript\">"; echo"functionjuge(theForm)"; echo"{"; echo"if(theForm.admin.value==\"\")"; echo"{"; echo"alert(\"请输入管理员名称!\");"; echo"theForm.admin.focus();";/*获取表单焦点*/ echo"return(false);"; echo"}"; echo"if(theForm.pass.value==\"\")"; echo"{"; echo"alert(\"请输入管理员密码1!\");"; echo"theForm.pass.focus();"; echo"return(false);"; echo"}"; echo"if(theForm.pass.value.length<8)"; echo"{"; echo"alert(\"密码至少要八位!\");"; echo"theForm.pass.focus();"; echo"return(false);"; echo"}"; echo"if(theForm.re_pass.value!=theForm.pass.value)";/*验证配置密码输入是否一致*/ echo"{"; echo"alert(\"确认密码与密码不一致\");"; echo"theForm.re_pass.focus();"; echo"return(false);"; echo"}"; echo"if(theForm.pre.value==\"\")"; echo"{"; echo"alert(\"请输入表前缀!\");"; echo"theForm.pre.focus();"; echo"return(false);"; echo"}"; echo"}"; echo"functions_photo(the)"; echo"{"; echo"document.img.src='images/'+the.photo.value+'.bmp';";/*获取配置图片*/ echo"}"; echo"</script>"; echo"<center>"; echo"<tablewidth\"%80\"cellpadding=\"1\"cellspacing\"1\">"; echo"<formmethod=\"post\"action=\"$PATH_INFO\"onsubmit\"returnjuge(this)\">"; echo"<tr>"; echo"<tdcolspan=\"2\"align=\"center\"><fontsize=\"5px\">安装程序</font></td>"; echo"</tr>"; echo"<tr>"; echo"<td>管理员:(后台登陆)</td>"; echo"<td><inputtype=\"text\"name=\"admin\"></td>"; echo"</tr>"; echo"<tr>"; echo"<td>管理员密码:(不小于八位)</td>"; echo"<td><inputtype=\"password\"name=\"pass\"size=\"21\"></td>"; echo"</tr>"; echo"<tr>"; echo"<td>确认密码:</td>"; echo"<td><inputtype=\"password\"name=\"re_pass\"size=\"21\"></td>"; echo"</tr>"; echo"<tr>"; echo"<td>管理员邮箱:(可选)</td>"; echo"<td><inputtype=\"text\"name=\"email\"></td>"; echo"</tr>"; echo"<tr>"; echo"<td>可选择的图像:</td>"; echo"<td>"; echo"<selectname=\"photo\"size=\"1\"onchange=\"s_photo(this.form)\">"; for($i=1;$i<21;$i++) { echo"<opionvalue=".$i.">".$i."</option>";; } echo"</select>"; echo"<imgsrc=\"images/1.bmp\"name=\"img\">"; echo"</td>"; echo"</tr>"; echo"<tr>"; echo"<td>用户地址:</td>"; echo"<td><inputtype=\"text\"name=\"address\"></td>"; echo"</tr>"; echo"<tr>"; echo"<tdcolspan=\"2\"><center>"; echo"<inputtype=\"submit\"value=\"下一步\">"; echo"<inputtype=\"reset\"value=\"重新填\">"; echo"</center><td/>"; echo"</tr>"; echo"</form>"; echo"</table>"; echo"</center>"; echo"</body>"; echo"</html>"; }else{ $name=$_POST['admin'];/*利用post方法保密传递用户名*/ $password=md5($_POST['pass']);/*利用post方法保密传递密码*/ $email=$_POST['email']; $photo=$_POST['photo']; $pre=$_POST['pre']; require"relate.php";/*利用前面php链接数据库*/ $table_user=$pre.$table_user; $table_type=$pre.$table_type; $table_thing=$pre.$table_thing; $table_order=$pre.$table_order; $table_sale=$pre.$table_sale; $time=date("Y年m月d日"); $sql="createtable$table_user( idint(5)notnullauto_incrementprimarykey, namevarchar(15)notnull, passwordvarchar(40)notnull, photovarchar(80)notnull, addressvarchar(80)notnull, emailvarchar(80)notnull, qqvarchar(15), msnvarchar(80), reg_datevarchar(20)notnull, post_numint(5)notnulldefault0, adminint(1)nutnull )"; mysql_query($sql,$link)ordie(mysql_error()); $sql="createtable$table_thing( idint(5)notnullauto_incrementprimarykey, p_idint(5)notnull, type_namevarchar(12)notnull, type_descriptionvarchar(80)notnull, type_numint(5)notnulldefault0 )"; mysql_query($sql,$link)ordie(mysql_error()); $sql="createtable$table_thing( idint(5)notnullauto_incrementprimarykey, thing_namevarchar(40)notnull, thing_authorvarchar(20)notnull, thing_pubvarchar(40)notnull, thing_nameint(5)notnull, thing_costvarchar(6)notnull, thing_descriptionvarchar(200)notnull, thing_photovachar(80)notnull, thing_sale_numint(5)notnull, thing_numint(5)notnull )"; mysql_query($sql,$link)ordie(mysql_error()); $sql="createtable$table_order( idint(5)notnullauto_incrementprimarykey, order_user_idint(5)notnull, order_user_namevarchar(12)notnull, order_thing_idint(5)notnull, order_thing_numint(5)notnull, order_contentvarchar(80)notnull, order_costvarchar(10)notnull, order_stateenum('true','false')notnulldefault'false', order_datevarchar(40)notnull )"; mysql_query($sql,$link)ordie(mysql_error()); $sql="createtable$table_sale( idint(5)notnullauto_incrementprimarykey, sale_order_idint(5)notnull, sale_datevarchar(40)notnull )"; mysql_query($sql,$link)ordie(mysql_error());$sql="insertinto$table_type(p_id,type_name,type_decription)values('0','主类别1','系统创建的默认主类别')"; $sql="insertinto$table_type(p_id,type_name,type_decription)values('0','分类别1','系统创建的默认分类别')";mysql_query($sql,$link)ordie(mysql_error()); $sql="insertinto$table_user(name,password,photo,address,,email,qq,msn,reg_date,admin) values('$name','$password','$photo','$email','$time''3')"; mysql_query($sql,$link)ordie(mysql_error()); $fp=fopen("relate.php","w+"); fputs($fp,"<?php"); fputs($fp,"\$db_host=\"localhost\";"); fputs($fp,"\$db_user=\"root\";"); fputs($fp,"\$db_pass=\"root\";"); fputs($fp,"\$db_name=\"shopping\";"); fputs($fp,"\$db_user=\"$table_user\";"); fputs($fp,"\$db_type=\"$table_type\";"); fputs($fp,"\$db_thing=\"$table_thing\";"); fputs($fp,"\$db_order=\"$table_order\";"); fputs($fp,"\$db_sale=\"$table_sale\";"); fputs($fp,"\$link=mysql_connect(\$db_hsot,\$db_user,\$db_pass);"); fputs($fp,"mysql_select_db(\$db_name,\$link);"); fputs($fp,"?>"); fclose($fp); echo"<center>"; echo"<tablewidth\"%80\"cellpadding=\"1\"cellspacing=\"1\">"; echo"<tr>"; echo"<tdalign=\"center\"><fontsize=\"5px\">安装程序</font></td>"; echo"</tr>"; echo"<tr>"; echo"<tdalign=\"center\"><fontsize=\"3px\">安装成功</font></td>"; echo"</tr>"; echo"<tr>"; echo"<tdalign=\"center\"><fontsize=\"3px\">删除文件减少风险</font></td>"; echo"</tr>"; echo"<tr>"; echo"<tdalign=\"center\">点<ahref=\".php\">击</a></td>"; echo"</tr>" echo"</table>"; echo"</center>"; echo"</body>";echo"</html>"; }?>4.3.3登陆功能<form

action="logincheck.php"

method="post">

用户名:<input

type="text"

name="username"

/>

<br

/>

密码:<input

type="password"

name="password"

/>

<br

/>

<input

type="submit"

name="submit"

value="登陆"

/>

<a

href="register.php">注册</a>

</form>/*基本表单*/

登录处理界面logincheck.php<?php

if(isset($_POST["submit"])

&&

$_POST["submit"]

==

"登陆")

{

$user

=

$_POST["username"];/*利用post方法传递用户名,密码,与数据库数据进行验证*/

$psw

=

$_POST["password"];

if($user

==

""

||

$psw

==

"")

{

echo

"<script>alert('请输入用户名或密码!');

history.go(-1);</script>";

}

else

{

mysql_connect("localhost","root","sixx");

mysql_select_db("vt");

mysql_query("set

names

'gbk'");

$sql

=

"select

username,password

from

user

where

username

=

'$_POST[usernae]'

and

password

=

'$_POST[password]'";

$result

=

mysql_query($sql);

$num

=

mysql_num_rows($result);

if($num)

{

$row

=

mysql_fetch_array($result);

//将数据以索引方式储存在数组中

echo

$row[0];

}

else

{

echo

"<script>alert('用户名或密码不正确!');history.go(-1);</script>";

}

}

}

else

{

echo

"<script>alert('提交未成功!');

history.go(-1);</script>";

}

?>

4.3.4注册<form

action="regcheck.php"

method="post">

用户名:<input

type="text"

name="username"/>

<br/>

密码:<input

type="password"

name="password"/>

<br/>

确认密码:<input

type="password"

name="confirm"/>

<br/>

<input

type="Submit"

name="Submit"

value="注册"/>

</form>

注册处理界面regcheck.php<?php

if(isset($_POST["Submit"])

&&

$_POST["Submit"]

==

"注册")

{

$user

=

$_POST["username"];

$psw

=

$_POST["password"];

$psw_confirm

=

$_POST["confirm"];

if($user

==

""

||

$psw

==

""

||

$psw_confirm

==

"")

{

echo

"<script>alert('请确认信息完整性!');

history.go(-1);</script>";

}

else

{

if($psw

==

$psw_confirm)

{

mysql_connect("localhost","root","sixx");

//连接数据库

mysql_select_db("vt");

//选择数据库

mysql_query("set

names

'gdk'");

//设定字符集

$sql

=

"select

username

from

user

where

username

=

'$_POST[username]'";

//SQL语句

$result

=

mysql_query($sql);

//执行SQL语句

$num

=

mysql_num_rows($result);

//统计执行结果影响的行数

4.3.5分页功能<?php

/*

*

Created

on

2013-12-3

*

分页类

*

To

change

the

template

for

this

generated

file

go

to

*

Window

-

Preferences

-

PHPeclipse

-

PHP

-

Code

Templates

*/

class

Pagination

{

private

$each_disNums;

//每页显示的条目数

private

$nums;

//总条目数

private

$current_page;

//当前被选中的页

private

$sub_pages;

//每次显示的页数

private

$pageNums;

//总页数

private

$page_array

=

array

();

//用来构造分页的数组

private

$subPage_link;

//每个分页的链接

private

$subPage_type;

//显示分页的类型

/*

__construct是SubPages的构造函数,用来在创建类的时候自动运行.

@$each_disNums

每页显示的条目数

@nums

总条目数

@current_num

当前被选中的页

@sub_pages

每次显示的页数

@subPage_link

每个分页的链接

@subPage_type

显示分页的类型

当@subPage_type=1的时候为普通分页模式

example:

共4523条记录,每页显示10条,当前第1/453页

[首页]

[上页]

[下页]

[尾页]

当@subPage_type=2的时候为经典分页样式

example:

当前第1/453页

[首页]

[上页]

1

2

3

4

5

6

7

8

9

10

[下页]

[尾页]

*/

function

__construct($each_disNums,

$nums,

$current_page,

$sub_pages,

$subPage_link,

$subPag_type)

{

$this->each_disNums

=

intval($each_disNums);

$this->nums

=

intval($nums);

if

(!$current_page)

{

$this->current_page

=

1;

}

else

{

$this->current_page

=

intval($current_page);

}

$this->sub_pages

=

intval($sub_pages);

$this->pageNums

=

ceil($nums

/

$each_disNums);

$this->subPage_link

=

$subPage_link;

$this->show_SubPages($subPage_type);

//echo

$this->pageNums."--".$this->sub_pages;

}

/*

__destruct析构函数,当类不在使用的时候调用,该函数用来释放资源。

*/

function

__destruct()

{

unset

($each_disNums);

unset

($nums);

unset

($current_page);

unset

($sub_pages);

unset

($pageNums);

unset

($page_array);

unset

($subPage_link);

unset

($subPage_type);

}

/*

show_SubPages函数用在构造函数里面。而且用来判断显示什么样子的分页

*/

function

show_SubPages($subPage_type)

{

if

($subPage_type

==

1)

{

$this->subPageCss1();

}

elseif

($subPage_type

==

2)

{

$this->subPageCss2();

}

}

/*

用来给建立分页的数组初始化的函数。

*/

function

initArray()

{

for

($i

=

0;

$i

<

$this->sub_pages;

$i++)

{

$this->page_array[$i]

=

$i;

}

return

$this->page_array;

}

/*

construct_num_Page该函数使用来构造显示的条目

即使:[1][2][3][4][5][6][7][8][9][10]

*/

function

construct_num_Page()

{

if

($this->pageNums

<

$this->sub_pages)

{

$current_array

=

array

();

for

($i

=

0;

$i

<

$this->pageNums;

$i++)

{

$current_array[$i]

=

$i

+1;

}

}

else

{

$current_array

=

$this->initArray();

if

($this->current_page

<=

3)

{

for

($i

=

0;

$i

<

count($current_array);

$i++)

{

$current_array[$i]

=

$i

+1;

}

}

elseif

($this->current_page

<=

$this->pageNums

&&

$this->current_page

>

$this->pageNums

$this->sub_pages

+

1)

{

for

($i

=

0;

$i

<

count($current_array);

$i++)

{

$current_array[$i]

=

($this->pageNums)

-

($this->sub_pages)

+

1

+

$i;

}

}

else

{

for

($i

=

0;

$i

<

count($current_array);

$i++)

{

$current_array[$i]

=

$this->current_page

-

2

+

$i;

}

}

}

return

$current_array;

}

/*

构造普通模式的分页

共4523条记录,每页显示10条,当前第1/453页

[首页]

[上页]

[下页]

[尾页]

*/

function

subPageCss1()

{

$subPageCss1Str

=

"";

$subPageCss1Str

.=

"共"

.

$this->nums

.

"条记录,";

$subPageCss1Str

.=

"每页显示"

.

$this->each_disNums

.

"条,";

$subPageCss1Str

.=

"当前第"

.

$this->current_page

.

"/"

.

$this->pageNums

.

"页

";

if

($this->current_page

>

1)

{

$firstPageUrl

=

$this->subPage_link

.

"1";

$prewPageUrl

=

$this->subPage_link

.

($this->current_page

-

1);

$subPageCss1Str

.=

"[<a

href='$firstPageUrl'>首页</a>]

";

$subPageCss1Str

.=

"[<a

href='$prewPageUrl'>上一页</a>]

";

}

else

{

$subPageCss1Str

.=

"[首页]

";

$subPageCss1Str

.=

"[上一页]

";

}

if

($this->current_page

<

$this->pageNums)

{

$lastPageUrl

=

$this->subPage_link

.

$this->pageNums;

$nextPageUrl

=

$this->subPage_link

.

($this->current_page

+

1);

$subPageCss1Str

.=

"

[<a

href='$nextPageUrl'>下一页</a>]

";

$subPageCss1Str

.=

"[<a

href='$lastPageUrl'>尾页</a>]

";

}

else

{

$subPageCss1Str

.=

"[下一页]

";

$subPageCss1Str

.=

"[尾页]

";

}

echo

$subPageCss1Str;

}

/*

构造经典模式的分页

当前第1/453页

[首页]

[上页]

1

2

3

4

5

6

7

8

9

10

[下页]

[尾页]

*/

function

subPageCss2()

{

$subPageCss2Str

=

"";

$subPageCss2Str

.=

"当前第"

.

$this->current_page

.

"/"

.

$this->pageNums

.

"页

";

if

($this->current_page

>

1)

{

$firstPageUrl

=

$this->subPage_link

.

"1";

$prewPageUrl

=

$this->subPage_link

.

($this->current_page

-

1);

$subPageCss2Str

.=

"

<a

href='$firstPageUrl'>首页</a>

";

$subPageCss2Str

.=

"

<a

href='$prewPageUrl'>上一页</a>

";

}

else

{

$subPageCss2Str

.=

"

首页

";

$subPageCss2Str

.=

"

上一页

";

}

$a

=

$this->construct_num_Page();

for

($i

=

0;

$i

<

count($a);

$i++)

{

$s

=

$a[$i];

i

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论