这学期PHP课程做的期末项目,嘛,懂得都懂~~~~,依旧很丑,很low,哈哈哈哈~~~~ 所用语言为html、js、css、mysql和php,所用的编译器DW,或者用VCS写代码,MySQL当时数据库、Wampserver64当php的服务用
目录描述
目录 | 作用 |
---|
System | 存放php系统框架的配置文件等 | Smatry | Php应用的一个整体框架 | pic | 商品图片存放位置 | Libs | Smatry的所需目录文件的配置 | System.inc.php | Smarty的类的所完成类的实例化 | Tmp | Php中section用法所产生的唯一的实例文件的集合 | Template | Smarty文件配置下的所属文件夹,用来存放tpl文件 | Tpl | Smarty文档中的模板文件的拓展名,实质是html文件 |
数据库表描述
表名 | 描述 |
---|
Tb_user | 用户表,用来存储用户注册后的信息 | Tb_commo | 商品表,用来存储商品详细信息 | Tb_form | 订单表,用来存储用户订单和收货信息 |
Tb_use表 Tb_commo表 Tb_form表
界面
(1) 登录界面
(2) 注册主页界面
(3) 商城主页界面 ennnn~~~~,还是移动端好看
(4) 购物车界面 (6) 提交订单界面
php中的部分代码
index.php
<?php
session_start();
header("content-type:text/html;charset=utf-8");
require("system/system.inc.php");
if(isset($_GET["page_type"])){
$page_type=$_GET["page_type"];
}
else{
$page_type="";
}
include_once("login.php");
include_once("public.php");
include_once("links.php");
switch($page_type){
case 'hyzx':
include_once('member.php');
$smarty->assign('admin_phtml','member.tpl');
break;
case 'shopcar':
include_once('myshopcar.php');
$smarty->assign('admin_phtml','myshopcar.tpl');
break;
case 'new':
include_once('allnew.php');
$smarty->assign('admin_phtml','allnew.tpl');
break;
case 'nom':
include_once('allnom.php');
$smarty->assign('admin_phtml','allnom.tpl');
break;
case 'hot':
include_once('allhot.php');
$smarty->assign('admin_phtml','allhot.tpl');
break;
case 'queryform':
include_once('queryform.php');
$smarty->assign('admin_phtml','queryform.tpl');
break;
default:
include_once('newhot.php');
$smarty->assign('admin_phtml','newhot.tpl');
break;
}
$smarty->display("index.tpl");
?>
login.php
<?php
if(empty($_SESSION['member'])){
$smarty->assign("member","游客");
}
else{
$smarty->assign("member",$_SESSION['member']);
}
?>
allhot.php
<?php
include_once("system/system.inc.php");
if(isset($_GET['page'])){
$page=$_GET['page'];
}
else{
$page=1;
}
$sql="select * from tb_commo order by sell desc";
$arrs=$seppage->ShowData($sql,$conn,12,$page);
$smarty->assign("hotarrs",$arrs);
$rst=$seppage->ShowPage("产品","个",$_GET['page_type'],'',"a");
$smarty->assign("rst_page",$rst);
$smarty->assign("title",'热门商品')
?>
allnew.php
<?php
include_once("system/system.inc.php");
if(isset($_GET['page'])){
$page=$_GET['page'];
}
else{
$page=1;
}
$sql="select * from tb_commo where isnew=1 order by isnew,id desc";
$rst1=$seppage->ShowData($sql,$conn,12,$page);
$smarty->assign("newarrs",$rst1);
$rst2=$seppage->ShowPage("产品","个",$_GET['page_type'],"","a");
$smarty->assign("rst1_page",$rst2);
$smarty->assign("title","最新商品");
?>
allnom.php
<?php
include_once("system/system.inc.php");
if(isset($_GET['page'])){
$page=$_GET['page'];
}
else{
$page=1;
}
$sql="select * from tb_commo where isnom=1 order by id desc";
$rst1=$seppage->ShowData($sql,$conn,12,$page);
$smarty->assign("nomarrs",$rst1);
$rst2=$seppage->ShowPage("产品","个",$_GET[page_type],"","a");
$smarty->assign("rst_page",$rst2);
$smarty->assign("title",'热门商品');
?>
changecar.php
chklogin.php
<?php
session_start();
header("content-type:text/html;charset=utf-8");
require("system/system.inc.php");
$reback='0';
$ids=explode(',',$_GET['ids']);
$nums=explode(',',$_GET['nums']);
$sql1="select * from tb_user where name='".$_SESSION['member']."'";
$rst1=$admindb->ExecSQL($sql1,$conn);
if($rst1==false){
$reback='2';
}
else{
']=20,1@24,1@23,1
$shopping=explode('@',$rst1[0]['shopping']); //$shopping={(20,1),(24,1),(23,1)}
foreach($shopping as $s_key=>$s_value){ //$s_value=(20,1),(24,1),(23,1)
$eachshopping=explode(',',$s_value); //$eachshopping={20,1}
foreach($ids as $i_key=>$i_value){ //$i_value=20,24,23
//找到对应的id,将数量填入
if($i_value==$eachshopping[0]){
//拼接成(20,1)
$eachs[0]=$i_value;
$eachs[1]=$nums[$s_key];
$tmp=implode(",",$eachs);
$tmpshop[$s_key]=$tmp;
}
}
}
$sql2="update tb_user set shopping='".implode('@',$tmpshop)."' where name='".$_SESSION['member']."'";
//echo $sql2;
$shop=$admindb->ExecSQL($sql2,$conn);
if($shop){
$reback='1';
}
else{
$reback='3';
}
}
echo $reback;
?>
chkname.php
<?php
session_start();
header("content-type:text/html;charset=utf-8");
require("system/system.inc.php");
$reback=0;
$sql="select * from tb_user where name='".$_GET['user']."'";
if(isset($_GET['password'])){
$sql.="and password='".$_GET['password']."'";
}
$rst=$admindb->ExecSQL($sql,$conn);
if($rst){
if($rst[0]['isfreeze']!=0){
$reback='3';
}else{
$_SESSION['member']=$rst[0]['name'];
$_SESSION['id']=$rst[0]['id'];
$reback='2';
}
}
else{
$reback='1';
}
echo $reback;
?>
delshop.php
<?php
session_start();
header("content-type:text/html;charset=utf-8");
require("system/system.inc.php");
$reback=0;
$commid=explode(',',$_GET['rd']);
$sql="select id,shopping from tb_user where name='".$_SESSION['member']."'";
$rst=$admindb->ExecSQL($sql,$conn);
if($rst==false){
$reback=2;
}
else{
if(!empty($rst[0]['shopping'])){
$shopping=explode('@',$rst[0]['shopping']);
foreach($shopping as $key=>$value1){
$tmp=explode(',',$value1);
$boo=false;
foreach($commid as $value){
if($value==$tmp[0]){
$boo=true;
}
}
if(!$boo){
$tmpshop[$key]=$value1;
}
}
if(!empty($tmpshop)){
$update="update tb_user set shopping='".implode('@',$tmpshop)."' where name='".$_SESSION['member']."'";
}
else{
$update="update tb_user set shopping='' where name='".$_SESSION['member']."'";
}
$shop=$admindb->ExecSQL($update,$conn);
if($shop){
$reback=1;
}
else {
$reback=3;
}
}
}
echo $reback;
?>
links.php
<?php
include_once("system/system.inc.php");
$sql="select id,name,url from tb_links order by id";
$link_arrs=$admindb->ExecSQL($sql,$conn);
$smarty->assign('link_arrs',$link_arrs)
?>
register.php
<?php
session_start();
header("content-type:text/html;charset=utf-8");
require("system/system.inc.php");
$name=$_POST['name'];
$password=$_POST['pwd1'];
$question=$_POST['question'];
$answer=$_POST['answer'];
$realname=$_POST['realname'];
$tel=$_POST['tel'];
$qq=$_POST['qq'];
$email=$_POST['email'];
$address=$_POST['address'];
$addtime=date("Y-m-d H:i:s");
$sql='insert into tb_user(name,password,question,answer,realname,card,tel,phone,Email,QQ,code,address,addtime,isfreeze,shopping,consume) ';
$sql.="values('$name','$password','$question','$answer','$realname','','$tel','','$email','$qq','','$address','$addtime',0,'',0)";
$rst=$admindb->ExecSQL($sql,$conn);
if($rst!=""){
$_SESSION['member']=$name;
echo "<script>alert('注册成功!');window.location.href='index.php';</script>";
}
else{
echo "<script>alert('注册失败!');histroy.back;</script>";
}
?>
修改mysql配置 SQL源文件位置
源码附上:https://gitee.com/Belong123/shop-php
|