当前位置:网站首页>Based on php animation peripheral mall management system (php graduation design)
Based on php animation peripheral mall management system (php graduation design)
2022-08-01 21:33:00 【Complete source code library】
基于phpAnimation peripheral mall management system
The animation peripheral mall management system is based onphp编程语言和mysql数据库开发的bs架构web系统,本系统拥有用户和管理员两个角色,The user has registered login,查看商品,buy add to cart,提交订单;管理员可以管理商品,添加商品,添加分类,查看订单,管理用户.This design is relatively simple,适合作为要求不高的毕业设计和课程设计参考和学习.
一.技术环境
php版本: 5.6 及以下
开发工具: notepad++,sublime,phpstorm都可
数据库: mysql
服务器: apache
集成环境: phpstudy,wamp
详细技术:HTML+CSS+JS+PHP+MYSQL+PhpStudy
二.项目文件
三.系统功能
四.代码示例
<?php
// +----------------------------------------------------------------------
// | 登录功能
// | 设计思路,获取到用户输入的账号和密码,验证用户输入的数据,验证通过,
// | 保存用户的登录信息到数据库,并且生成cookie,提示用户登录成功
// +----------------------------------------------------------------------
//引用常用的函数
require_once('../../../config/config.php');
//获取登录的用户名
$name = $_POST['name'];
//获取用户的登录密码
$password = $_POST['password'];
//获取登录的角色
$role = $_POST['role'];
//判断用户输入的用户名是否为空
if (!$name) {
//如果为空,返回提示信息
ajaxReturn(0, '请输入用户名');
}
//判断用户输入的密码是否为空
if (!$password) {
ajaxReturn(0,'请输入密码');
}
//sql语句
$sql = "SELECT * FROM users WHERE name='$name' AND password='$password'";
//查询数据库用户记录,fetchOne函数在mysql.php里
$result = fetchOne($link,$sql);
//如果没有查询到此用户
if(!$result) {
ajaxReturn(0,'抱歉,登录名和密码错误!');
}else {
//保存用户的session
$user = array(
'id'=>$result['id'],
'name'=>$result['name'],
'avatar' =>$result['avatar'],
'role'=>$result['role']
);
//如果是用户登录
if($role == 1) {
if($result['role'] == 1){
//设置session,失效时间1小时
$_SESSION["user"]=$user;
ajaxReturn(1,'恭喜你,登录成功!');
}else{
ajaxReturn(0,'抱歉,你不是用户!');
}
}
//如果是管理员登录
if($role == 2 ) {
//判断是否是管理员
if($result['is_admin'] == 1) {
//设置session,失效时间1小时
$_SESSION["admin"]=$user;
//提示登录成功
ajaxReturn(2,'恭喜你,登录成功!');
}else{
//如果不是管理员,给予提示
ajaxReturn(0,'抱歉,你不是管理员!');
}
}
}
<?php
// +----------------------------------------------------------------------
// | 注册功能
// | 设计思路,首先判断用户输入的数据是否正确,在判断用户的邮箱有没有注
// | 过,满足条件,注册成功,ajaxReturn函数在include.php中
// +----------------------------------------------------------------------
//引用常用的函数
require_once('../../../config/config.php');
//获取前台发来的数据
$name = $_POST['name'];//获取用户名
$password = $_POST['password'];//获取密码
$email = $_POST['email'];//获取游戏
$password_o = $_POST['password_o'];//获取重复密码
//判断用户名
if(!$name) {
ajaxReturn(0,'用户名格式不正确,英文加数字!');
}
//判断密码是否输入正确
if(!is_password($password)) {
ajaxReturn(0,'密码格式不正确,不少于6位!');
}
//判断邮箱是否输入正确
if(!is_email($email)) {
ajaxReturn(0,'邮箱格式不正确!');
}
//判断两次密码输入是否一致
if($password != $password_o) {
ajaxReturn(0,'两次输入的密码不一致!');
}
//查询数据库是否已经注册过此邮箱
$sql = "SELECT * FROM users WHERE email='$email'";
$result1 = fetchAll($link,$sql);
if($result1) {
ajaxReturn(0,'抱歉,此邮箱已经注册过!');
}
$data = array(
'name'=>$name,
'password'=>$password,
'email'=> $email,
'addtime'=>date('Y-m-d H:i:s')
);
//保存用户的注册信息到users表,其中的$link在include.php里
$result2 = insert($link,$data,'users');
//注册成功和失败的话,返回提示
if(!$result2) {
ajaxReturn(0,'注册失败!');
}else{
ajaxReturn(1,'恭喜你注册成功');
}
五.项目截图
边栏推荐
猜你喜欢
随机推荐
空间数据库开源路,超图+openGauss风起禹贡
附录A printf、varargs与stdarg A.3 stdarg.h ANSI版的varargs.h
C陷阱与缺陷 第7章 可移植性缺陷 7.9 大小写转换
Based on php film and television information website management system acquisition (php graduation design)
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.2 Early Experience of C Language
Spark cluster construction
An online JVM FullGC made it impossible to sleep all night and completely crashed~
C陷阱与缺陷 第7章 可移植性缺陷 7.8 随机数的大小
shell规范与变量
用户量大,Redis没法缓存响应,数据库宕机?如何排查解决?
C Pitfalls and Defects Chapter 7 Portability Defects 7.11 An Example of a Portability Problem
FusionGAN:A generative adversarial network for infrared and visible image fusion article study notes
上传markdown文档到博客园
C pitfalls and pitfalls Chapter 7. Portability pitfalls 7.10 Free first, then realloc
ISC2022 HackingClub白帽峰会倒计时1天!最全议程正式公布!元宇宙集结,精彩绝伦!
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.4 K&R C
C专家编程 第1章 C:穿越时空的迷雾 1.2 C语言的早期体验
How to choose Visibility, Display, and Opacity when interacting or animating
MySQL相关知识
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.3 The Standard I/O Library and the C Preprocessor