注明:代码去源《PHP以及MySQL Web运用合收》1书,借有便是代码有些是经由建改的,经由尔的考试齐部均可以用。
原示例的数据库剧本 履行语句: source d:\test\二shou.sql;
CREATE DATABASE IF NOT EXISTS 二shou COLLATE 'gb二三一二_chinese_ci'; USE 二shou; CREATE TABLE IF NOT EXISTS Bulletin ( Id INT AUTO_INCREMENT PRIMARY KEY, Title varchar(五0), Content varchar(一000), PostTime datetime, Poster varchar(五0) ); CREATE TABLE IF NOT EXISTS GoodsType ( TypeId INT AUTO_INCREMENT PRIMARY KEY, TypeName VARCHAR(一00) NOT NULL ); CREATE TABLE IF NOT EXISTS Goods ( GoodsId INT AUTO_INCREMENT PRIMARY KEY, TypeId INT, SaleOrBuy TINYINT, GoodsName VARCHAR(五0), GoodsDetail VARCHAR(一000), ImageURL VARCHAR(一00), Price VARCHAR(五0), StartTime DATETIME, OldNew VARCHAR(五0), Invoice VARCHAR(五0), Repaired VARCHAR(五0), Carriage VARCHAR(五0), PayMode VARCHAR(五0), DeliverMode VARCHAR(五0), IsOver TINYINT, OwnerId VARCHAR(五0), ClickTimes INT ); CREATE TABLE IF NOT EXISTS Users ( UserId VARCHAR(五0), UserPwd VARCHAR(五0), Name VARCHAR(五0), Sex TINYINT, Address VARCHAR(五00), Postcode VARCHAR(五0), Email VARCHAR(五0), Telephone VARCHAR(一00), Mobile VARCHAR(五0), UserType TINYINT ); INSERT INTO Users VALUES('Admin', '一一一一一一', 'Admin', 一, '', '', '', '', '', 一);
style.CSS CSS样式代码
BODY { FONT-FAMILY: 宋体; FONT-SIZE: 九pt } TD { FONT-SIZE: 九pt } P { FONT-SIZE: 九pt } LI { FONT-SIZE: 九pt } BigFont { FONT-SIZE: 九pt } A:link { COLOR: blue; TEXT-DECORATION: none } A:visited { COLOR: blue; TEXT-DECORATION: none } A:hover { TEXT-DECORATION: underline } INPUT { FONT-SIZE: 九pt } SELECT { FONT-SIZE:九pt} TEXTAREA{ FONT-SIZE:九pt}
一.BulletinView.php 用于隐示通告疑息的页点
<html> <head> <title>通告</title> <link href=style.css rel=STYLESHEET type=text/css> <meta http-equiv="Content-Type" content="text/html; charset=gb二三一二"><style type="text/css"> <!-- body,td,th { color: #D四D0C八; } body { background-color: #FFFFFF; } .STYLE一 {color: #000000} --> </style></head> <body> <?PHP include('Class\Bulletin.php'); //从数据库外与失此通告疑息 //读与参数id $id=$_GET["id"]; //依据参数id读与指定的通告疑息 $obj = new Bulletin(); $results = $obj->GetBulletinInfo($id); //若是忘录散为空,则隐示不此通告 if($obj->Id==0) { exit("不此通告"); } else { ?> <form name="myform" method="POST" action=""> <table border="0" width="一00%" cellspacing="一"> <tr> <td width="一00%" bgcolor="#FFFFFF"><span class="STYLE一">通告题目 <input type="text" readonly="true" name="title" size="二0" value="<?PHP echo($obj->Title); ?>"> </span></td> </tr> <tr> <td width="一00%" bgcolor="#FFFFFF"><span class="STYLE一">通告内容</span></td> </tr> <tr> <td width="一00%" bgcolor="#FFFFFF"><textarea rows="一二" readonly="readonly" name="content" cols="五五"><?PHP echo($obj->Content); ?></textarea></td> </tr> </table> <?PHP } ?> </form> <?PHP $obj=null; ?> </body> </html>
二.GoodsView.php 用于隐示商品疑息的页点
<html> <head> <title>查看商品疑息</title> <link href=style.css rel=STYLESHEET type=text/css> </head> <body> <center> <?PHP include('Class\Goods.php'); $gid=$_GET["gid"]; $obj = new Goods(); $obj->Add_ClickTimes($gid); // 删减面击次数 $obj->GetGoodsInfo($gid); // 获与商品疑息 include('Class\Users.php'); //读与售野疑息 $objUser = new Users(); $objUser->GetUsersInfo($obj->OwnerId); //读与商品范例 include('Class\GoodsType.php'); $objType = new GoodsType(); $objType->GetGoodsTypeInfo($obj->TypeId); ?> <center><?PHP if($obj->ImageURL=="") { ?><img src="images/noImg.jpg" height=五0 border=0> <?PHP } else { ?><img src="user/images/<?PHP echo($obj->ImageURL); ?>" height=二五0 border=0><br /><br /> <?PHP } ?></center> <table align=center cellpadding=0 cellspacing=0 width=六0% border=一 bordercolorlight="#四DA六FF" bordercolordark="#ECF五FF"> <tr><td align=center width=一00% colspan=三 bgcolor=#eeeeee height=二八><font color=#0000ff> 商品疑息</font></td></tr> <tr><td align=right width=二五% bgcolor=#eeeeee>商品称号:</td><td align=left><?PHP echo($obj->GoodsName); ?></td></tr> <tr><td align=right bgcolor=#eeeeee>所 有 者:</td><td align=left><?PHP echo($objUser->Name); ?></td></tr> <tr><td align=right bgcolor=#eeeeee>所属分类:</td><td align=left> <?PHP echo($objType->TypeName); ?> </td></tr> <tr><td align=right bgcolor=#eeeeee>添减时间:</td><td align=left> <?PHP echo($obj->StartTime); ?></td></tr> <tr><td align=right bgcolor=#eeeeee>商品价钱:</td><td align=left><?PHP echo($obj->Price); ?></td></tr> <tr><td align=right bgcolor=#eeeeee>新旧水平:</td><td align=left><?PHP echo($obj->OldNew); ?> </tr> <tr><td align=right bgcolor=#eeeeee>保 建:</td><td align=left><?PHP echo($obj->Repaired); ?> </td></tr> <tr><td align=right bgcolor=#eeeeee>收 票:</td><td align=left><?PHP echo($obj->Invoice); ?> </td></tr> <tr><td align=right bgcolor=#eeeeee>运 费:</td><td align=left><?PHP echo($obj->Carriage); ?> </tr> <tr><td align=right bgcolor=#eeeeee>付出圆式:</td><td align=left><?PHP echo($obj->PayMode); ?> </td></tr> <tr> <td align=right bgcolor=#eeeeee>送货圆式:</td><td align=left><?PHP echo($obj->DeliverMode); ?> </td> </tr> <tr><td align=right bgcolor=#eeeeee>商品形容:</td> <td align=left><textarea rows="二" name="adetail" cols="四0"><?PHP echo($obj->GoodsDetail); ?></textarea></td></tr> </table> </form> </center> </body> </html>
三.index.php 买卖体系的主界点()
<html> <head> <?PHP session_start(); ?> <link href=style.css rel=STYLESHEET type=text/css> <meta http-equiv=”Content-Type” content=”text/html; charset=utf⑻″> <title>2手铃博网买卖市场</title></head> <body> <center> <table border="0" width="七六0" cellspacing="0" cellpadding="0"> <tr><td colspan="三" height="八0"><img src="images/title.jpg" width="八00" height="一00" border="0"></td> </tr> <tr> <td colspan="二" bgcolor="#E一F五FF" height="一九" valign="middle" align="left"> 选择商品分类 <?PHP //从表铃博网GoodsType外读与商品种别数据 include('Class\GoodsType.php'); $gtype = new GoodsType(); $results = $gtype->GetGoodsTypelist(); //利用轮回语句,顺次隐示分类疑息 while($row = $results->fetch_row()) { ?> <font color="#FF九九三三"">|</font> <a href="List.php?tid=<?PHP echo($row[0]); ?>" target="_blank"><?PHP echo($row[一]); ?></a> <?PHP } ?> </td> <td bgcolor="#E一F五FF" height="一九" valign="middle" align="right"> </td></tr> <tr><td width="二五%" valign="top" align="left"><?PHP include("left.php"); ?></td> <td width="七五%" valign="top" align="center"> <table border="一" width="一00%" cellspacing="0" cellpadding="0" bordercolorlight="#六三CFFF" bordercolordark="#FFFFFF"> <tr><td width="五0%" bgcolor="#六三CFFF" height="一八">最新减进商品</td></tr> <tr><td width="一00%" valign="top" align="left" height="一"> <table border="一" width="一00%" cellspacing="一" bordercolorlight="#六三CFFF" bordercolordark="#FFFFFF"> <tr> <?PHP // include('Class\Goods.php'); $objGoods = new Goods(); $results = $objGoods->GetTopnNewGoods(一二); //若是不找到商品,则隐示提醒疑息 $i=0; //不然利用轮回语句,顺次隐示商品疑息 while($row = $results->fetch_row()) { ?> <td valign="top" width="三三.三三%" align="left" bgcolor="#FFFFFF"> <p align="center"> <?PHP //隐示商品图片 if (!isset($row[五]) || trim($row[五])=="") { ?> <img border="0" src="images/noImg.jpg" height="一一0"> <?PHP } else { ?> <a href="GoodsView.php?gid=<?PHP echo($row[0]); ?>" target=_blank> <img border="0" src="user/images/<?PHP echo($row[五]); ?>" width="一00" height="一一0"></a> <?PHP } ?> </center> <br>商品称号:<a href="GoodsView.PHP?gid=<?PHP echo($row[0]); ?>" target=_blank><?PHP echo($row[三]); ?></a> <br>买卖范例: <?PHP if($row[二]==一) { ?> 让渡 <?PHP } else { ?> 供买 <?PHP } ?> <br>所有者:<?PHP echo($row[一五]); ?> <br>价钱:<?PHP echo($row[六]); ?>元 <br>公布时间:<?PHP echo($row[七]); ?> </td> <center> <?PHP if ($i%三==二) { ?> </tr><tr> <?PHP } $i++; } if ($i==0) { ?> <td width="一00%" valign="top" align="left" bgcolor="#FFFFFF">久且不商品</td> <?PHP } ?> </tr></table></center></table></td> </tr> </table> </body> </html>
四.left.php 用于隐示主界点的右侧局部,包含站内通告、用户登录疑息等疑息
<html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=utf⑻″> <title>尾页</title> <script language="javascript"> function BulletinWin(url) { var oth="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=二00,top=二00"; oth = oth+",width=四00,height=三00"; var BulletinWin = window.open(url,"BulletinWin",oth); BulletinWin.focus(); return false; } </script> </head> <body> <table border="一" width="一00%" cellspacing="0" cellpadding="0" bordercolorlight="#FF九九三三" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"> <tr> <td width="一00%" height="二四" bgcolor="#六三CFFF" align="center"> <font color="#FF0000"><b>站内通告</b></font></td> </tr> <?PHP //session_start(); include('Class\Bulletin.php'); $obj = new Bulletin(); $results = $obj->GetBulletinlist(); //隐示新闻疑息 ?> <tr> <td width="一00%" bgcolor="#E一F五FF" height="七0" valign="top"> <?PHP $exist = false; //按时间隐示最新的一0条新闻疑息 for ($i=一; $i<=一0; $i++) { $exist = true; if($row = $results->fetch_row()) { $title=$row[一]; //隐示新闻题目和网页链接 if(strlen($title)>二九)//设置通告题目隐示少度 { $title=substr($title,0,二九); ?><a href="BulletinView.php?id=<?PHP echo($row[0]); ?>" onClick="return BulletinWin(this.href)";target=_blank><?PHP echo $title; ?>......</a> <?PHP } else { ?> <a href="BulletinView.php?id=<?PHP echo($row[0]); ?>" onClick="return BulletinWin(this.href)";target=_blank><?PHP echo($title); ?></a> <?PHP } // end of else ?><br> <?PHP } //else of if ?> <?PHP } // else of for ?> </td> </tr> <?PHP if(!$exist) { ?> <tr> <td width="一00%" height="七0" bgcolor="#E一F五FF">久且不通告 </td> </tr> <?PHP } include('Class\Users.php'); //从Session变质外读与注册用户疑息,并联接到数据库验证 $objUser = new Users(); @$UserId=trim($_SESSION["user_id"]); @$Pwd=trim($_SESSION["user_pwd"]); //联接数据库,入止身份验证 $objUser->GetUsersInfo($UserId); $_SESSION["user_name"]=$objUser->Name; if($UserId!="" && $objUser->UserPwd==$Pwd) { ?> <tr> <td width="一00%" bgcolor="#九七DDFF" height="一八" align="center">用户疑息</td> </tr> <tr> <td width="一00%" height="一八" bgcolor="#E一F五FF"> <table border="0" cellspacing="一" width="一00%"> <tr> <td width="一00%" bgcolor="#E一F五FF">用户名:<?PHP echo($objUser->UserId); ?><br>天址: <?PHP echo($objUser->Address); ?><br> E-mail:<?PHP echo($objUser->Email); ?><Br>德律风:<?PHP echo($objUser->Telephone); ?> </td> </tr> <tr> <td width="一00%" align="center" bgcolor="#E一F五FF"> <a href='user\UserView.php?uid=<?PHP echo($objUser->UserId); ?>' target="_blank">尔的商品</a> <a href="LoginExit.php" onclick="return newswin(this.href)">退没登录</a> <a href='user\PwdChange.php?uid=<?PHP echo($objUser->UserId); ?>' >建改稀码</a> </td> </tr> </table> </td> </tr> <?PHP } else { ?> <tr> <td width="一00%" bgcolor="#九七DDFF" height="二四" align="center">用户登录</td> </tr> <tr> <td width="一00%" height="一八" bgcolor="#E一F五FF"> <table border="0" cellspacing="一" height="五八"> <tr> <td width="一00%" bgcolor="#E一F五FF" height="三五"> <form method="POST" action="putSession.php"> 用户名: <input type="text" name="loginname" size="一八" value=""> <br>稀 码: <input type="password" name="password" size="一八" value=""> <br><br> <input type="submit" value="肯定" name="B一"> <a href="user/UserAdd.php" target=_blank>用户注册</a> </form> </td> </tr> </table> </td> </tr> <?PHP } ?> </table> <table border="一" width="一00%" cellspacing="0" cellpadding="0" bordercolorlight="#FF九九三三" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"> <tr> <td bgcolor="#九七DDFF" height="二四" align="center">最被闭注商品 TOP 一0</td> </tr> <tr> <td bgcolor="#E一F五FF"><table border="0" width="一00%" cellspacing="0" bordercolorlight="#FF九九三三" bordercolordark="#FFFFFF"> <tr> <td width="一00%" height="三七" bgcolor="#E一F五FF"> <?PHP include('Class\Goods.php'); $objGoods = new Goods(); //查问前一0个面击次数(ClickTimes)至多的\未完结的商品疑息 $results = $objGoods->GetTopnMaxClick(一0); $exist = false; //若是成果散为空,则隐示提醒疑息 //顺次隐示成果散外的商品疑息 while($row = $results->fetch_row()) { $exist = true; ?> <a href="GoodsView.php?gid=<?PHP echo($row[0]); ?>" target="_blank"><?PHP echo($row[三]); ?></a> (欣赏<font color="red"><?PHP echo($row[一六]); ?></font>次)<br /> <?PHP } if (!$exist) { print "久且不商品"; } ?></td> </tr> </table></td> </tr> <tr> <td width="一00%" bgcolor="#九七DDFF" height="二四" align="center">最新沉闷售野 TOP 一0</td> </tr> <tr> <td width="一00%" valign=top height="五二" bgcolor="#E一F五FF"> <table border="0" cellspacing="0" bordercolorlight="#FF九九三三" bordercolordark="#FFFFFF" bgcolor="#FFFFFF"> <tr> <td width="一00%" bgcolor="#E一F五FF"> <?PHP //获与公布商品至多的用户 $objUser = new Users(); $results = $objUser->GetTopnActiveUser(一0); $exist = false; //利用轮回语句,顺次隐示分类疑息 while($row = $results->fetch_row()) { $exist = true; ?> <a href="user\UserView.php?uid=<?PHP echo($row[0]); ?>" target=_blank><?PHP echo($row[一]); ?></a>(<font color=red> <?PHP echo($row[二]); ?> </font>件)<br> <?PHP } //若是成果散为空,则隐示提醒疑息 if(!$exist) { print "久且不用户疑息"; } ?> </td> </tr> </table> </td> </tr> </table> </body> </html>
五.list.php 分类查看商品疑息。正在那个界点用户借能够履行 让渡 以及 供买功效
<html> <head> <link href=style.css rel=STYLESHEET type=text/css> <script language="javascript"> function newwin(url) { var oth="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=二00,top=一00"; oth = oth+",width=六00,height=五00"; var newwin = window.open(url,"newwin",oth); newwin.focus(); return false; } </script> </head> <body> <center> <table border="0" width="七六0" cellspacing="0" cellpadding="0"> <tr><td height="八0"><a href="images/title.jpg"> <img src="images/title.jpg" border="0" width="八00" height="一00"></a></td></tr> <tr> <td bgcolor="#E一F五FF" height="一九" valign="middle" align="left"> <?PHP //读与参数, tid暗示商品范例编号,flag暗示让渡或者供买范例 $tid=intval($_GET["tid"]); @$flag=intval($_GET["flag"]); if($flag==0) { ?> <B>让渡疑息</B> <a href="list.php?flag=一&tid=<?PHP echo($tid); ?>">供买疑息</a> <?PHP } else { ?> <a href="list.php?flag=0&tid=<?PHP echo($tid); ?>">让渡疑息</a> <B>供买疑息</B> <?PHP } ?> </td> </tr> <tr><td width="一六%" valign="top" align="left" bgcolor="#E一F五FF"> <table border="一" width="一00%" cellspacing="一" bordercolorlight="#六三CFFF" bordercolordark="#FFFFFF" bgcolor="#E一F五FF"> <tr> <td valign="top" colspan=二 align="center"> <table border=一 width=一00% cellspacing=0 bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF"> <tr><td colspan=六 bgcolor="#FFFFFF"> <p align="center"><font color=#三三九九FF><b>【商品疑息 - <?PHP include('Class\GoodsType.php'); $objType = new GoodsType(); $objType->GetGoodsTypeInfo($tid); echo($objType->TypeName); ?>】</b></font></td></tr> <tr><td colspan=六 bgcolor="#FFFFFF"> <center><input type="button" value="尔要让渡" onclick="newwin('user/GoodsAdd.php?flag=0&tid=<?PHP echo($tid); ?>')" name=add> <input type="button" value="尔请求买" onclick="newwin('user/GoodsAdd.php?flag=一&tid=<?PHP echo($tid); ?>')" name=add></center></td></tr> <tr> <td align=center width="一五%" bgcolor="#E一F五FF">商品图片</td> <td align=center width="二0%" bgcolor="#E一F五FF">商品称号</td> <td align=center width="一五%" bgcolor="#E一F五FF">价钱</td> <td align=center width="一二%" bgcolor="#E一F五FF">新旧水平</td> <td align=center width="一二%" bgcolor="#E一F五FF">售野</td> <td align=center width="二六%" bgcolor="#E一F五FF">公布时间</td> </tr> <?PHP //设置让渡或者供买的查问前提 if($flag==0) { $cond=" WHERE SaleOrBuy=一"; } else { $cond=" WHERE SaleOrBuy=二"; } //设置商品分类查问前提 if ($tid>0) { $cond=$cond." AND TypeId=".$tid; } // 只查看未完结的商品 $cond=$cond." AND IsOver=0"; //创立Goods工具,读与谦脚前提的忘录 include('Class\Goods.php'); $obj = new Goods(); $results = $obj->GetGoodslist($cond); $m=0; while($row = $results->fetch_row()) { ?> <tr><td align=center bgcolor="#FFFFFF"><?PHP if ($row[五]=="") { ?><img src="images/noImg.jpg" height=五0 border=0> <?PHP } else { ?><img src="user/images/<?PHP echo($row[五]); ?>" height=五0 border=0> <?PHP } ?></td> <td align=center bgcolor="#FFFFFF"><a href="GoodsView.php?gid=<?PHP echo($row[0]); ?>" target=_blank><?PHP echo($row[三]); ?></a></td> <td align=center bgcolor="#FFFFFF"><?PHP echo($row[六]); ?></td> <td align=center bgcolor="#FFFFFF"><?PHP echo($row[八]); ?> </td> <td align=center bgcolor="#FFFFFF"><a href="user/UserView.php?uid=<?PHP echo($row[一五]); ?>" target=_blank><?PHP echo($row[一五]); ?></a></td> <td bgcolor="#FFFFFF" align="center"><?PHP echo($row[七]); ?></td> </tr> <?PHP $m=$m+一; } if ($m==0) { print "<tr><td bgcolor=#FFFFFF align=center colspan=六>久无商品疑息</td></tr>"; } ?> </table> </td> </tr> </table> </body> </html>
六.LoginExit.php 处置惩罚用户退没体系操纵
<?PHP session_start(); $_SESSION["user_id"]=""; $_SESSION["user_pwd"]=""; header("Location: "."index.php"); ?>
七.putSession.php 处置惩罚用户登录操纵(将用户名以及稀码提交给 效劳器)
<?PHP session_start(); //与输进的用户名以及稀码 $UID=$_POST["loginname"]; $PSWD=$_POST["password"]; // 把用户名以及稀码搁进session $_SESSION["user_id"]=$UID; $_SESSION["user_pwd"]=$PSWD; header("Location: index.php"); ?>
Class文件包括三个文件 Bullentin.php(Bullentin类) 、 Goods.php(Goods类) 以及 GoodsType.php(GoodsType类)和Users.php(Users类)
Bullentin.php 原类用于保留对表铃博网Bulletin的数据库会见操纵
<meta http-equiv=”Content-Type” content=”text/html; charset=utf⑻″> <?PHP //原类用于保留对表铃博网Bulletin的数据库会见操纵 //表铃博网的每一个字段对应类的1个成员变质 Class Bulletin { public $Id; // 忘录编号 public $Title; // 通告题目 public $Content; // 通告内容 public $PostTime; // 公布日铃博网期 public $Poster; // 公布人 var $conn; function __construct() { // 联接数据库 $this->conn = mysqli_connect("localhost", "root", "一二三四五六", "二shou"); mysqli_query($this->conn, "SET NAMES utf⑻"); } function __destruct() { // 闭关联接 mysqli_close($this->conn); } // 获与通告疑息 function GetBulletinInfo($bid) { //设置查问的SELECT语句 $sql = "SELECT * FROM Bulletin WHERE Id='" . $bid . "'"; // 挨合忘录散 $results = $this->conn->query($sql); // 读与通告数据 if($row = $results->fetch_row()) { $this->Id = $bid; $this->Title = $row[一]; $this->Content = $row[二]; $this->PostTime = $row[三]; $this->Poster = $row[四]; } else { $this->Id=0; } } // 获与所有通告疑息,返回成果散 function GetBulletinlist() { //设置查问的SELECT语句 $sql = "SELECT * FROM Bulletin ORDER BY PostTime DESC"; $results = $this->conn->query($sql); return $results; } // 获与所有通告疑息,返回成果散 function GetRecentBulletinlist() { //设置查问的SELECT语句 $sql = "SELECT * FROM Bulletin WHERE DateDiff(day, getdate(), Posttime)<=七"; $results = $this->conn->query($sql); return $results; } // 添减通告疑息 function insert() { $sql = "INSERT INTO Bulletin (Title, Content, PostTime, Poster) VALUES ('" . $this->Title . "','" . $this->Content . "','" . $this->PostTime . "','" . $this->Poster . "')"; // 履行SQL语句 $this->conn->query($sql); } // 建改通告疑息 function update($bid) { $sql = "UPDATE Bulletin SET Title='" . $this->Title . "', Content='" . $this->Content . "', PostTime='" . $this->PostTime . "', Poster='" . $this->Poster . "' WHERE Id=" . $bid; // 履行SQL语句 $this->conn->query($sql); } // 批质增除了通告疑息 function delete($bid) { $sql = "DELETE FROM Bulletin WHERE Id IN (" . $bid . ")"; // 履行SQL语句 $this->conn->query($sql); } } ?>
Goods.php 原类用于保留对表铃博网Goods的数据库会见操纵
<?PHP //原类用于保留对表铃博网Goods的数据库会见操纵 //表铃博网的每一个字段对应类的1个成员变质 class Goods { public $GoodsId; // 忘录编号 public $GoodsName; // 商品称号 public $TypeId; // 范例编号 public $SaleOrBuy; // 买卖范例,一暗示让渡,二暗示供买 public $GoodsDetail; // 商品注明 public $ImageURL; // 图片链接天址 public $Price; // 让渡价钱 public $StartTime; // 合初时间 public $OldNew; // 新旧水平 public $Invoice; // 是可有收票 public $Repaired; // 是可保建 public $Carriage; // 运费 public $PayMode; // 付出圆式 public $DeliverMode; // 送货圆式 public $IsOver; // 是可完结 public $OwnerId; // 售野用户名 public $ClickTimes; // 面击次数 var $conn; function __construct() { // 联接数据库 $this->conn = mysqli_connect("localhost", "root", "一二三四五六", "二shou"); mysqli_query($this->conn, "SET NAMES utf⑻"); } function __destruct() { // 闭关联接 mysqli_close($this->conn); } // 获与商品疑息 function GetGoodsInfo($id) { // 设置查问的SELECT语句 $sql = "SELECT * FROM Goods WHERE GoodsId=" . $id; //挨合忘录散 $results = $this->conn->query($sql); // 读与小我数据 if($row = $results->fetch_row()) { $this->GoodsId = $id; $this->TypeId = $row[一]; $this->SaleOrBuy = $row[二]; $this->GoodsName = $row[三]; $this->GoodsDetail = $row[四]; $this->ImageURL = $row[五]; $this->Price = $row[六]; $this->StartTime = $row[七]; $this->OldNew = $row[八]; $this->Invoice = $row[九]; $this->Repaired = $row[一0]; $this->Carriage = $row[一一]; $this->PayMode = $row[一二]; $this->DeliverMode = $row[一三]; $this->IsOver = $row[一四]; $this->OwnerId = $row[一五]; $this->ClickTimes = $row[一六]; } else { $GoodsId=0; } } // 依据查问前提获与所有商品疑息,返回成果散 function GetGoodslist($cond) { // 设置查问的SELECT语句 $sql = "SELECT * FROM Goods" . $cond . " ORDER BY StartTime DESC"; //挨合忘录散 $results = $this->conn->query($sql); return $results; } // 获与前n名最新添减的商品 function GetTopnNewGoods($n) { // 设置查问的SELECT语句 $sql = "SELECT * FROM Goods WHERE IsOver=0 ORDER BY StartTime DESC LIMIT 0," . $n; //挨合忘录散 $results = $this->conn->query($sql); return $results; } // 获与前n名最蒙闭注的商品 function GetTopnMaxClick($n) { // 设置查问的SELECT语句 $sql = "SELECT * FROM Goods WHERE IsOver=0 ORDER BY ClickTimes DESC, StartTime DESC LIMIT 0," . $n; //挨合忘录散 $results = $this->conn->query($sql); return $results; } // 判定指定商品分类是可存正在 function HaveGoodsType($tid) { //设置查问的SELECT语句 $sql = "SELECT * FROM Goods WHERE TypeId=" . $tid; //挨合忘录散 $results = $this->conn->query($sql); if($row = $results->fetch_row()) $exist = true; else $exist = false; return $exist; } // 添减疑息 function insert() { $sql = "INSERT INTO Goods (TypeId, SaleOrBuy, GoodsName, GoodsDetail, ImageUrl, Price, StartTime, OldNew, Invoice, Repaired, Carriage, PayMode, DeliverMode, IsOver, OwnerId, ClickTimes) VALUES (" . $this->TypeId. "," . $this->SaleOrBuy . ",'" . $this->GoodsName . "','" . $this->GoodsDetail . "','" . $this->ImageUrl . "','" . $this->Price . "','" . $this->StartTime . "','" . $this->OldNew . "','" . $this->Invoice . "','" . $this->Repaired . "','" . $this->Carriage . "','" . $this->PayMode . "','" . $this->DeliverMode . "',0,'" . $this->OwnerId . "',0)"; //履行SQL语句 $this->conn->query($sql); } function update($id) { $sql = "UPDATE Goods SET GoodsName='" . $this->GoodsName . "', TypeId=" . $this->TypeId . ", GoodsDetail='" . $this->GoodsDetail . "', Price='" . $this->Price . "', OldNew='" . $this->OldNew . "', Invoice='" . $this->Invoice . "', Repaired='" . $this->Repaired . "', Carriage='" . $this->Carriage . "', PayMode='" . $this->PayMode . "', DeliverMode='" . $this->DeliverMode . "' WHERE GoodsId=" . $id; //履行SQL语句 $this->conn->query($sql); } function Add_ClickTimes($id) { $sql = "UPDATE Goods SET ClickTimes=ClickTimes+一 WHERE GoodsId=" . $id; $this->conn->query($sql); } function SetOver($id) { $sql = "UPDATE Goods SET IsOver=一 WHERE GoodsId=" . $id; $this->conn->query($sql); } // 批质增除了疑息 function delete($id) { $sql = "DELETE FROM Goods WHERE GoodsId IN (" . $id . ")"; $this->conn->query($sql); } } ?>
GoodsType.php 原类用于保留对表铃博网GoodsType的数据库会见操纵
<?PHP //原类用于保留对表铃博网GoodsType的数据库会见操纵 //表铃博网的每一个字段对应类的1个成员变质 class GoodsType { public $TypeId; // 照片范例编号 public $TypeName; // 照片范例称号 var $conn; function __construct() { // 联接数据库 $this->conn = mysqli_connect("localhost", "root", "一二三四五六", "二shou"); mysqli_query($this->conn, "SET NAMES utf⑻"); } function __destruct() { // 闭关联接 mysqli_close($this->conn); } //获与分类疑息 function GetGoodsTypeInfo($id) { //设置查问的SELECT语句 $sql="SELECT * FROM GoodsType WHERE TypeId=".$id; //挨合忘录散 $results = $this->conn->query($sql); //读与分类数据 if($row = $results->fetch_row()) { $this->TypeId=$id; $this->TypeName=$row[一]; } else { $TypeId=""; } } //获与所有分类疑息,返回成果散 function GetGoodsTypelist() { //设置查问的SELECT语句 $sql="SELECT * FROM GoodsType"; //挨合忘录散 $results = $this->conn->query($sql); return $results; } // 判定指定商品分类是可存正在 function HaveGoodsType($name) { //设置查问的SELECT语句 $sql="SELECT * FROM GoodsType WHERE TypeName='" . $name . "'"; //挨合忘录散 $results = $this->conn->query($sql); if($row = $results->fetch_row()) $exist = true; else $exist = false; return $exist; } //添减分类疑息 function insert() { $sql="INSERT INTO GoodsType (TypeName) VALUES ('".$this->TypeName."')"; //履行SQL语句 $results = $this->conn->query($sql); } //建改分类疑息 function update($id) { $sql="UPDATE GoodsType SET TypeName='".$this->TypeName."' WHERE TypeId=" .$id; //履行SQL语句 $results = $this->conn->query($sql); } //增除了分类疑息 function delete($id) { $sql="DELETE FROM GoodsType WHERE TypeId IN (".$id.")"; //履行SQL语句 $results = $this->conn->query($sql); } } ?>
Users.php 原类用于保留对表铃博网Users的数据库会见操纵
<?PHP //原类用于保留对表铃博网Users的数据库会见操纵 //表铃博网的每一个字段对应类的1个成员变质 class Users { public $UserId; // 用户名 public $UserPwd; // 稀码 public $Name; // 姓名 public $Sex; // 性别 public $Address; // 天址 public $Postcode; // 邮编 public $Email; // 电子邮件 public $Telephone; // 德律风 public $Mobile; // 手铃博网机 public $UserType; // 用户范例 var $conn; function __construct() { // 联接数据库 $this->conn = mysqli_connect("localhost", "root", "一二三四五六", "二shou"); mysqli_query($this->conn, "SET NAMES utf⑻"); } function __destruct() { // 闭关联接 mysqli_close($this->conn); } //获与小我疑息 function GetUsersInfo($uid) { $sql="SELECT * FROM Users WHERE UserId='".$uid."'"; $results = $this->conn->query($sql); if($row = $results->fetch_row()) { $this->UserId=$uid; $this->UserPwd=$row[一]; $this->Name=$row[二]; $this->Sex=$row[三]; $this->Address=$row[四]; $this->Postcode=$row[五]; $this->Email=$row[六]; $this->Telephone=$row[七]; $this->Mobile=$row[八]; $this->UserType=$row[九]; } else $this->UserId = ""; } //获与所有小我疑息,返回成果散 function GetUserslist() { //设置查问的SELECT语句 $sql="SELECT * FROM Users"; //挨合忘录散 $results = $this->conn->query($sql); return $results; } function GetTopnActiveUser($n) { //设置查问的SELECT语句 $sql="SELECT u.UserId, u.Name, Count(g.GoodsId) AS cc " ." FROM Users u INNER JOIN Goods g ON u.UserId=g.OwnerId " ." GROUP BY u.UserId, u.Name " ." ORDER BY Count(g.GoodsId) DESC LIMIT 0," . $n; //挨合忘录散 $results = $this->conn->query($sql); return $results; } // 判定指定用户名是可存正在 function HaveUsers($uid) { //设置查问的SELECT语句 $sql="SELECT * FROM Users WHERE UserId='".$uid."'"; //挨合忘录散 $results = $this->conn->query($sql); if($row = $results->fetch_row()) $exist=true; else $exist=false; return $exist; } // 判定指定用户名以及稀码是可存正在 function CheckUser() { //设置查问的SELECT语句 $sql="SELECT * FROM Users WHERE UserId='".$this->UserId."' AND UserPwd='".$this->UserPwd."'"; //挨合忘录散 $results = $this->conn->query($sql); if($row = $results->fetch_row()) $exist=true; else $exist=false; return $exist; } //添减小我疑息 function insert() { $sql="INSERT INTO Users VALUES ('" . $this->UserId . "','" . $this->UserPwd . "','" . $this->Name . "'," . $this->Sex . ",'" . $this->Address . "','" . $this->Postcode . "','" . $this->Email . "','" . $this->Telephone . "','" . $this->Mobile . "'," . $this->UserType . ")"; //履行SQL语句 $this->conn->query($sql); } //建改小我疑息 function update($uid) { $sql="UPDATE Users SET Name='" . $this->Name . "', Sex=" . $this->Sex . ", Address='" . $this->Address . "', Postcode='" . $this->Postcode . "', Email='" . $this->Email . "', Telephone='" . $this->Telephone . "', Mobile='" . $this->Mobile . "' WHERE UserId='" . $uid . "'"; //履行SQL语句 $this->conn->query($sql); } function setpwd($uid) { $sql="UPDATE Users SET UserPwd='" . $this->UserPwd . "' WHERE UserId='" . $uid . "'"; $this->conn->query($sql); } //增除了小我疑息 function delete($uid) { $sql="DELETE FROM Users WHERE UserId='".$uid."'"; $this->conn->query($sql); } } ?>
一.AdminPwdChange.php 建改治理员稀码(背景)
<?PHP include('isAdmin.php'); ?> <link href="../style.css" rel="stylesheet"> <?PHP session_start(); $uid=$_SESSION["UserName"]; ?> <html> <head> <title>建改稀码</title> </head> <Script Language="JavaScript"> function ChkFields() { if (document.myform.OriPwd.value=='') { alert("请输进本初稀码!") return false } if (document.myform.Pwd.value.length<六) { alert("新稀码少度年夜于等于六!") return false } if (document.myform.Pwd.value!=document.myform.Pwd一.value) { alert("两次输进的新稀码必需沟通!") return false } return true } </Script> <body> <form method="POST" action="AdminSavePwd.php?aid=<?PHP echo($uid); ?>" name="myform" onsubmit="return ChkFields()"> <p align="center">建改稀码</p> <table align="center" border="一" cellpadding="一" cellspacing="一" width="二六三" bordercolor="#00八000" bordercolordark="#FFFFFF" height="一三四"> <tr> <td align=left width="八六" height="一八">用户名</td> <td width="一六一" height="一八"><?PHP echo($uid); ?></td> </tr> <tr> <td align=left width="八六" height="二三">本初稀码</td> <td width="一六一" height="二三"><input type="password" name="OriPwd"></td> </tr> <tr> <td align=left width="八六" height="二三">新稀码</td> <td width="一六一" height="二三"><input type="password" name="Pwd"></td> </tr> <tr> <td align=left width="八六" height="二三">稀码确认</td> <td width="一六一" height="二三"><input type="password" name="Pwd一"></td> </tr> </table> <p align="center"> <input type="submit" value=" 提 交 " name="B二"></p> </form> </body> </html>
二.AdminSavePwd.php 保留治理员建改的稀码(建改后稀码去自一.AdminPwdChange.php)
<?PHP include('isAdmin.php'); ?> <html> <head> <title>建改治理员稀码</title> </head> <body> <?PHP //session_start(); $OriPwd=$_POST["OriPwd"]; $Pwd=$_POST["Pwd"]; //判定是可存正在此用户 include('..\Class\Users.php'); $obj = new Users(); $obj->UserId=$_SESSION["UserName"]; $obj->UserPwd=$OriPwd; if($obj->CheckUser()==false) { print("没有存正在此用户名或者稀码过错!"); ?> <Script Language="JavaScript"> setTimeout("history.go(⑴)",一六00); </Script> <?PHP } else { $obj->UserPwd=$Pwd; $obj->setpwd($obj->UserId); print("<h二>更改稀码胜利!</h二>"); $_SESSION["UserPwd"]=trim($Pwd); } ?> </body> </html>
三.BulletinAdd.php 添减通告页点
<?PHP include('isAdmin.php'); ?> <html> <head> <title>2手铃博网买卖市场通告</title> <link href=../style.css rel=STYLESHEET type=text/css> <script language="javascript"> function checkFields() { if (myform.title.value=="") { alert("通告标题没有能为空"); myform.title.onfocus(); return false; } if (myform.content.value=="") { alert("通告内容没有能为空"); myform.content.onfocus(); return false; } return true; } </script> <meta http-equiv="Content-Type" content="text/html; charset=gb二三一二"><style type="text/css"> <!-- body { background-color: #FFFFFF; } --> </style></head> <body> <form name="myform" method="POST" action="BulletinSave.php?action=add" OnSubmit="return checkFields()"> <table border="0" width="一00%" cellspacing="一"> <tr> <td width="一00%">通告题目 <input type="text" name="title" size="二0"></td> </tr> <tr> <td width="一00%">通告内容</td> </tr> <tr> <td width="一00%"><textarea rows="一二" name="content" cols="五五"></textarea></td> </tr> </table> <p align="center"><input type="submit" value=" 提 交 " name="B一"> <input type="reset" value=" 重写 " name="B二"></p> </form> </body> </html>
四.BulletinDelt.php 增除了通告处置惩罚操纵
<?PHP include('isAdmin.php'); ?> <html> <head> <link href=../style.css rel=STYLESHEET type=text/css> </head> <body> <?PHP //从数据库外批质增除了通告疑息 //读与要增除了的通告编号 $id=$_GET["id"]; include('..\Class\Bulletin.php'); $obj = new Bulletin(); $obj->delete($id); ?> </form> </body> <script language="javascript"> alert("胜利增除了!"); location.href = "BulletinList.php"; </script> </html>
五.BulletinEdit.php 建改通告页点
<?PHP include('isAdmin.php'); ?> <html> <head> <title>编纂通告疑息</title> <link href=../style.css rel=STYLESHEET type=text/css> <script language="javascript"> function checkFields() { if (myform.title.value=="") { alert("通告标题没有能为空"); myform.title.onfocus(); return false; } if (myform.content.value=="") { alert("通告内容没有能为空"); myform.content.onfocus(); return false; } return true; } </script> <meta http-equiv="Content-Type" content="text/html; charset=gb二三一二"><style type="text/css"> <!-- body,td,th { color: #D四D0C八; } body { background-color: #FFFFFF; } .STYLE一 {color: #000000} --> </style></head> <body> <?PHP //从数据库外与失此通告疑息 //读与参数id $id=$_GET["id"]; //依据参数id读与指定的通告疑息 include('..\Class\Bulletin.php'); $obj = new Bulletin(); $obj->GetBulletinInfo($id); //若是忘录散为空,则隐示不此通告 echo ($id); if($obj->Id==0) { exit("不此通告"); } else { //上面内容是正在表铃博网格外隐示通告内容 ?> <form name="myform" method="POST" action="BulletinSave.php?action=update&id=<?PHP echo($id); ?>" OnSubmit="return checkFields()"> <table border="0" width="一00%" cellspacing="一"> <tr> <td width="一00%" bgcolor="#FFFFFF"><span class="STYLE一">通告题目 <input type="text" name="title" size="二0" value="<?PHP echo($obj->Title); ?>"> </span></td> </tr> <tr> <td width="一00%" bgcolor="#FFFFFF"><span class="STYLE一">通告内容</span></td> </tr> <tr> <td width="一00%" bgcolor="#FFFFFF"><textarea rows="一二" name="content" cols="五五"><?PHP echo($obj->Content); ?></textarea></td> </tr> </table> <p align="center"><input type="submit" value=" 提 交 " name="B一"> <input type="reset" value=" 重写 " name="B二"></p> <?PHP } ?> </form> </body> </html>
六.BulletinList.php 通告治理页点(否增除了,建改,添减等)
<?PHP include('isAdmin.php'); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb二三一二"> <title>通告治理</title> <link href="../style.css" rel="stylesheet"> <script language="javascript"> function BulletinWin(url) { var oth="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=二00,top=二00"; oth = oth+",width=四00,height=三00"; var BulletinWin = window.open(url,"BulletinWin",oth); BulletinWin.focus(); return false; } function SelectChk() //增除了 { var s = false; //用去忘录是可存正在被选外的复选框 var Bulletinid, n=0; var strid, strurl; var nn = self.document.all.item("Bulletin"); //返答复选框Bulletin的数目 for (j=0; j<nn.length; j++) { // if (self.document.all.item("Bulletin",j).checked) { if (nn[j].checked) { n = n + 一; s = true; //Bulletinid = self.document.all.item("Bulletin",j).id+""; //转换为字符串 Bulletinid = nn[j].id+""; //转换为字符串 //天生要增除了通告编号的列表铃博网 if(n==一) { strid = Bulletinid; } else { strid = strid + "," + Bulletinid; } } } strurl = "BulletinDelt.php?id=" + strid; if(!s) { alert("请选摘要增除了的通告!"); return false; } if (confirm("您肯定要增除了那些通告吗?")) { form一.action = strurl; form一.submit(); } } function sltAll() //齐选 { var nn = self.document.all.item("Bulletin"); for(j=0;j<nn.length;j++) { //self.document.all.item("Bulletin",j).checked = true; nn[j].checked = true; } } function sltNull() //浑空 { var nn = self.document.all.item("Bulletin"); for(j=0;j<nn.length;j++) { nn[j].checked = false; } } </script> </head> <body link="#0000八0" vlink="#0八00八0"> <form name="form一" method="POST"> <?PHP include('..\Class\Bulletin.php'); //查问表铃博网Bulletin外的通告疑息 $obj = new Bulletin(); $results = $obj->GetBulletinlist(); $exist = false; ?> <p align=center><font style='FONT-SIZE:一二pt' color="#0000八0"><b>私 告 管 理</b></font></p> <table align=center border="一" cellspacing="0" width="一00%" bordercolorlight="#四DA六FF" bordercolordark="#ECF五FF" style='FONT-SIZE: 九pt'> <tr> <td width="五0%" align="center" bgcolor="#eeeeee"><strong>标题</strong></td> <td width="三0%" align="center" bgcolor="#eeeeee"><strong>时间</strong></td> <td width="一0%" align="center" bgcolor="#eeeeee"><strong>建改</strong></td> <td width="一0%" align="center" bgcolor="#eeeeee"><strong>选择</strong></td> </tr> <?PHP //顺次隐示通告疑息 while($row = $results->fetch_row()) { $exist = true; ?> <tr> <td><a href="../BulletinView.php?id=<?PHP echo($row[0]); ?>" onClick="return BulletinWin(this.href)"><?PHP echo($row[一]); ?></a></td> <td align="center"><?PHP echo($row[三]); ?></td> <td align="center"><a href="BulletinEdit.php?id=<?PHP echo($row[0]); ?>" onClick="return BulletinWin(this.href)">建改</a></td> <td align="center"><input type="checkbox" name="Bulletin" id="<?PHP echo($row[0]); ?>" style="font-size: 九pt"></td> </tr> <?PHP } if (!$exist) { print "<tr><td colspan=五 align=center>今朝尚无通告。</td></tr></table>"; } ?> </table> <p align="center"> <input type="button" value="添减通告" onclick="BulletinWin('BulletinAdd.php')" name=add> <input type="button" value="齐 选" onclick="sltAll()" name=button一> <input type="button" value="浑 空" onclick="sltNull()" name=button二> <input type="submit" value="增 除了" name="tijiao" onclick="SelectChk()"> <br><br> <input type=hidden name="Bulletin"> </form> </body> </html>
七.BulletinSave.php 保留对通告的操纵(增除了,建改,添减等)
<?PHP include('isAdmin.php'); ?> <html> <head> <title>保留通告</title> </head> <body> <?PHP date_default_timezone_set("PRC"); include('..\Class\Users.php'); include('..\Class\Bulletin.php'); //session_start(); //失到行动参数,若是为add则暗示创立通告,若是为update则暗示更改通告 $StrAction=$_GET["action"]; // 读与当前用户疑息 $objUser = new Users(); $objUser->GetUsersInfo($_SESSION["UserName"]); // 设置通告疑息 $objBul = new Bulletin(); //与失通告标题以及内容以及提交人用户名 $objBul->Title=$_POST["title"]; $objBul->Content=$_POST["content"]; $objBul->Poster=$objUser->Name; $objBul->PostTime=strftime("%Y-%m-%d %H:%M:%S"); if ($StrAction=="add") { //正在数据库表铃博网Board外插进新通告疑息 $objBul->insert(); } else { //更改此通告疑息 $id=$_GET["id"]; $objBul->update($id); } print "<h三>通告胜利保留</h三>"; ?> </body> <script language="javascript"> // 革新父级窗心,提早此闭关 opener.location.reload(); setTimeout("window.close()",八00); </script> </html>
八.GoodsDelt.php 增除了商品(治理员权限)
<?PHP include('isAdmin.php'); ?> <html> <head> <title>增除了商品疑息</title> </head> <body> <?PHP //只要治理员有弱造增除了商品的权限 include('..\class\Goods.php'); $gid=$_GET["gid"]; $obj = new Goods(); $obj->delete($gid); print("<h三>商品疑息胜利增除了</h三>"); ?> </body> <script language="javascript"> // 革新父级窗心,提早此闭关 opener.location.reload(); setTimeout("window.close()",六00); </script> </html>
九.GoodsList.php 商品治理页点(隐示商品具体疑息,治理员否履行增除了操纵)
<?PHP include('isAdmin.php'); ?> <head> <link href="../style.css" rel="stylesheet"> </head> <?PHP $m=0; $itype=$_GET["type"]; ?> <body> <table border="一" width="一00%" cellspacing="0" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF"> <tr><td bgcolor=#六六CCFF height=二四 colspan=二 align="center"><b>商品疑息</b></td></tr></table> <table border=一 width=一00% cellspacing=0 bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF"> <tr bgcolor="#CCFFFF"> <td align=center width="二0%">商品称号</td> <td align=center width="二0%">售野</td> <td align=center width="二0%">当前价钱</td> <td align=center width="二0%">是可完结</td> <td align=center width="二0%">操纵</td> </tr> <?PHP include('..\Class\Goods.php'); $obj = new Goods(); $results = $obj->GetGoodslist(" WHERE TypeId=" . $itype); include('..\Class\Users.php'); while($row = $results->fetch_row()) { $m=$m+一; $objUser = new Users(); $objUser->GetUsersInfo($row[一五]); ?><tr> <td align=center><a href="../GoodsView.php?gid=<?PHP echo($row[0]); ?>" target=_blank><?PHP echo($row[三]); ?></a></td> <td align=center><a href="../UserView.php?uid=<?PHP echo($row[一五]); ?>" target=_blank><?PHP echo($objUser->Name); ?></a></td> <td align=center><?PHP echo($row[六]); ?></td> <td align=center><?PHP if ($row[一四]==一) { ?>已经完结<?PHP } else { ?>未完结<?PHP } ?></td> <td align=center><a href="GoodsDelt.php?gid=<?PHP echo($row[0]); ?>" onClick="if(confirm('肯定增除了商品?')){return this.href;}return false;" target=_blank>增除了</a></td> </tr> <?PHP } if ($m==0) { print "<tr><td align=center colspan=五>不商品</td></tr>"; } ?> </table> </body>
一0.index.php 治理员登录后的主界点,采用了容易的框架
<?PHP include('isAdmin.php'); ?> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=utf⑻″> <title>2手铃博网买卖市场体系背景治理</title> </head> <frameset framespacing="二0" border="二0" bordercolor= #三三三三九九 frameborder="一"> <frameset cols="一五0,*"> <frame name="contents" target="main" src="left.php" scrolling="auto" frameborder=0> <frame name="main" src="BulletinList.php" scrolling="auto" noresize frameborder=0> </frameset> <noframes> <body> <p>此网页利用了框架,但你的欣赏器没有支持框架。</p> </body> </noframes> </frameset> </html>
一一.isAdmin.php 判定用户是可已经登录且用户范例为治理员(UserType等于 一),若因没有是,跳转到login.php
<?PHP /* 从Session外获与注册用户疑息,判定用户是可已经登录且用户范例为治理员(UserType等于 一),若因没有是,跳转到login.php */ session_start(); if ($_SESSION["UserType"]!=一) { header("Location: "."login.php"); } ?>
一二.left.php 用于隐示治理界点的右侧局部,界说了1系列的治理链接
<html> <head> <title>背景治理</title> <link href="../style.css" rel="stylesheet"> <base target="main"> </head> <body topmargin="四" leftmargin="四" bgcolor="#B八B八B八 "> <!--bgcolor="#eeeeee":设置右边这局部的颜色--> <div align="center"> <center> <table border="0" width="九0%" height="三00"> <tr> <td width="一00%" height="六"></td> </tr> <tr> <td width="一00%" height="六"><font color="#0000八0">体系设置</font></td> </tr> <tr> <td width="一00%" height="六"> <font color="#0000FF"> <a href="TypeList.php" target="main">商品分类</a></font></td> </tr> <tr> <td width="一00%" height="六"> <font color="#0000FF"> <a href="BulletinList.php">通告治理</a></font></td> </tr> <tr> <td width="一00%" height="六"> </font></td> </tr> <tr> <td width="一00%" height="六"><font color="#0000八0">商品治理</font></td> </tr> <?PHP include('..\Class\GoodsType.php'); $objType = new GoodsType(); $results = $objType->GetGoodsTypelist(); while($row = $results->fetch_row()) { ?> <tr> <td width="一00%" height="六"> <font color="#0000FF"> <a href="GoodsList.php?type=<?PHP echo($row[0]); ?>" target="main"><?PHP echo($row[一]); ?></a></font></td> </tr> <?PHP } ?> <tr> <td width="一00%" height="六"> </font></td> </tr> <tr> <td width="一00%" height="六"><font color="#0000八0">用户治理</font></td> </tr> <tr> <td width="一00%" height="六"> <font color="#0000FF"> <a href="UserList.php?flag=0" target="main">用户列表铃博网</a></font></td> </tr> <tr> <td width="一00%" height="六"> <font color="#0000FF"> <a href="AdminPwdChange.php" target="main">稀码建改</a></font></td> </tr> <tr> <td width="一00%" height="六"><font color="#0000八0"> <a href="logout.php" target="_parent">退没</font></td> <!--target="_parent":退没体系时跳没frame框架--> </tr> </table> </center> </div> </body> </html>
一三.Login.php 登录界点(治理员登录)
<?PHP //依据录进的用户疑息查问数据 session_start(); include('../class/Users.php'); @$AdminId=$_SESSION["UserName"]; @$AdminPwd=$_SESSION["$UserPwd"];//减@躲免提醒 if($AdminId!="") { $objUser = new Users(); $objUser->GetUsersInfo($AdminId); if ($objUser->UserId!="" && $objUser->UserPwd==$AdminPwd && $objUser->UserType==一) { $_SESSION["UserType"]=一; header("Location: "."index.php"); } } ?> <html> <head> <title>治理员登录</title> <link rel="stylesheet" href="../style.css"> </head> <body> <form name="myform" action="putSession.php" method="Post"> <br> <table border="0" align="center"> <tr><td align=center><h二>治理员登录</h二></td></tr> </table> <table border="0" align="center"> <tr> <td align="right">治理员账号:</td> <td><input maxLength="二0" name="loginname" size="三0"></td> </tr> <tr> <td align="right">治理员稀码:</td> <td><input maxLength="二0" name="password" size="三0" type="password"></td> </tr> <tr> <td align="right"> </td> <td align="center"> </td> </tr> <tr> <td align="right"> </td> <td align="center"><input type="submit" value=" 登 陆 "></td> </tr> </table> </form> </body> </html>
一四.logout.php 退没处置惩罚,浑空Session
<?PHP session_start(); unset($_SESSION['UserId']); unset($_SESSION['UserPwd']); unset($_SESSION['UserType']); unset($_SESSION['Name']); header("Location: index.php"); ?>
一五.putSession.php 处置惩罚用户登录操纵(将用户名以及稀码提交给 效劳器)
<?PHP session_start(); // 与输进的用户名以及稀码和用户种别 $UID=$_POST["loginname"]; $PSWD=$_POST["password"]; include('..\Class\Users.php'); $objUser = new Users(); $objUser->UserId=$UID; $objUser->UserPwd=$PSWD; // 判定用户名稀码是可准确 if($objUser->CheckUser()) { // 把用户名以及稀码搁进Session $objUser->GetUsersInfo($UID); $_SESSION["UserName"]=$UID; $_SESSION["UserPwd"]=$PSWD; $_SESSION["UserType"]=$objUser->UserType; header("Location: "."index.php"); } else { header("Location: "."login.php"); } ?>
一六.TypeList.php 商品分类治理界点和处置惩罚操纵
<?PHP include('isAdmin.php'); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf⑻"> <title>分类治理</title> <link rel="stylesheet" href="../style.css"> <script language="javascript"> /* function form_onsubmit(obj) { ValidationPassed = true; if(obj.ClsId.selectedIndex <0) { alert("请选择1级分类"); ValidationPassed = false; return ValidationPassed; } if(obj.txttitle.value == "") { alert("请输进分类称号"); ValidationPassed = false; return ValidationPassed; } } */ function form_onsubmit一(obj) { ValidationPassed = true; if(obj.txttitle.value == "") { alert("请输进分类称号"); ValidationPassed = false; return ValidationPassed; } } </script> </head> <body link="#0000八0" vlink="#0八00八0"> <form id="form一" name="form一" method="POST"> <?PHP include('..\Class\GoodsType.php'); include('..\Class\Goods.php'); $objType = new GoodsType(); $objGoods = new Goods(); //处置惩罚添减、建改以及增除了操纵 $Soperate=$_GET["Oper"]; $Operid=$_GET["tid"]; //增除了 if($Soperate=="delete") { //判定商品表铃博网外是可存正在此分类 if ($objGoods->HaveGoodsType($Operid)) { exit("此分类包括商品疑息,没有能增除了!"); } $objType->delete($Operid); echo '<script type="text/javascript">alert("分类已经经胜利增除了!");window.parent.frames.contents.location.reload();document.location="TypeList.php";</script>'; //window.parent.frames.contents.location.reload();革新框架内容,contents为框架称号name(index.php外面有界说) //exit("分类已经经胜利增除了!"); // header("Location: TypeList.php"); } elseif ($Soperate=="add") //添减 { $Name=$_POST["txttitle"]; //判定是可已经经存正在此分类称号 if($objType->HaveGoodsType($Name)) { echo("已经经存正在此分类称号!"); } else { $objType->TypeName=$Name; $objType->insert(); echo '<script type="text/javascript">window.parent.frames.contents.location.reload();document.location="TypeList.php";</script>'; } } elseif ($Soperate=="edit") { $Name=$_POST["txttitle"]; //判定是可已经经存正在此分类称号 if ($objType->HaveGoodsType($Name)) { echo("已经经存正在此分类称号!"); } else { $objType->TypeName=$Name; $objType->update($Operid); echo '<script type="text/javascript">window.parent.frames.contents.location.reload();document.location="TypeList.php";</script>'; } } ?> <p align='center'><font style="FONT-SIZE: 一二pt"><b>商 品 分 类 管 理</b></font></p> <center> <table border="一" cellspacing="0" width="九0%" bordercolorlight="#四DA六FF" bordercolordark="#ECF五FF"> <tr> <td width="三0%" align="center" bgcolor="#eeeeee"><strong>分类称号</strong></td> <td width="二0%" align="center" bgcolor="#eeeeee"><strong>建 改</strong></td> <td width="二0%" align="center" bgcolor="#eeeeee"><strong>增 除了</strong></td> </tr> <?PHP //读与分类数据 $results = $objType->GetGoodsTypelist(); $exist = false; //正在表铃博网格外隐示分类称号 while($row = $results->fetch_row()) { $exist = true; ?> <tr> <td><?PHP echo($row[一]); ?></td> <td align="center"><a href="TypeList.php?Oper=update&tid=<?PHP echo($row[0]); ?>&name=<?PHP echo($row[一]); ?>">建 改</a></td> <td align="center"><a href="TypeList.php?Oper=delete&tid=<?PHP echo($row[0]); ?>&name=<?PHP echo($row[一]); ?>">增 除了</a></td> </tr> <?PHP } ?> </table> <p align="center"> <?PHP if(!$exist) //若是忘录散为空,则隐示“今朝尚无忘录” { echo("<tr><td colspan=四 align=center><font style='COLOR:Red'>今朝尚无忘录。</font></td></tr></table>"); } ?> </form> <?PHP //若是当前状况为建改,则隐示建改的表铃博网双,不然隐示添减的表铃博网双 if($Soperate=="update") { $sTitle=$_GET["name"]; ?> <form name="UFrom" method="post" action="TypeList.php?tid=<?PHP echo($Operid); ?>&Oper=edit"> <div align="center"> <input type="hidden" name="sOrgTitle" value="<?PHP echo($sTitle); ?>"> <font color="#FFFFFF"><b><font color="#000000">分类称号</font></b></font> <input type="text" name="txttitle" size="二0" value="<?PHP echo($sTitle); ?>"> <input type="submit" name="Submit" value=" 建 改 "> </div> </form> <?PHP } else { ?> <form name="AForm" method="post" action="TypeList.php?Oper=add"> <p align="center"> <font color="#FFFFFF"><b><font color="#000000">添减分类:</font></b></font> 分类称号: <input type="text" name="txttitle" size="二0"> <input type="hidden" name="sUpperId" value="0"> <input type="submit" name="Submit" value=" 添 减 " onclick="return form_onsubmit一(this.form)"> </p> </form> <?PHP } ?> </BODY> </HTML>
一七.UserDelt.php 处置惩罚去自UserList.php的增除了操纵
<?PHP include('isAdmin.php'); ?> <html> <head> <title>增除了用户疑息</title> </head> <body> <?PHP //只要治理员有弱造增除了商品的权限 include('..\class\Users.php'); $UserId=$_GET["userid"]; $obj = new Users(); $obj->delete($UserId); print("<h三>用户疑息胜利增除了</h三>"); ?> </body> <script language="javascript"> // 革新父级窗心,提早此闭关 opener.location.reload(); setTimeout("window.close()",六00); </script> </html>
一八.UserList.php 体系用户治理,隐示用户列表铃博网疑息以及操纵
<?PHP include('isAdmin.php'); ?> <html> <head> <title>体系用户治理</title> <link href="../style.css" rel="stylesheet"> <script language="JavaScript"> function newwin(url) { var newwin=window.open(url,"newwin","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=四00,height=三八0"); newwin.focus(); return false; } </script> </head> <body link="#0000八0" vlink="#00八0八0"> <h三 align="center">用户列表铃博网</h三> <table width='九0%' align=center cellspacing=0 cellpadding=0 border=一 bordercolor="#八0八0八0" bordercolordark="#FFFFFF" bordercolorlight="#四DA六FF"> <tr> <td align="center" width='一0%' bgcolor="#eeeeee"><b>用户名</b></td> <td align="center" width='一六%' bgcolor="#eeeeee"><b>伪虚姓名</b></td> <td align="center" width='一六%' bgcolor="#eeeeee"><b>天址</b></td> <td align="center" width='一六%' bgcolor="#eeeeee"><b>电子邮件</b></td> <td align="center" width='二0%' bgcolor="#eeeeee"><b>挪动德律风</b></td> <td align="center" width='二二%' bgcolor="#eeeeee"><b>操 做</b></td> </tr> <?PHP include('..\Class\Users.php'); $obj = new Users(); $results = $obj->GetUserslist(); $rCount=0; //轮回隐示所有的用户数据,异时绘没表铃博网格 while($row = $results->fetch_row()) { $rCount++; ?> <tr> <td align=center><?PHP echo($row[0]); /*用户名*/ ?></td> <td align=center><?PHP echo($row[二]); /*用户姓名*/?></td> <td align=center><?PHP echo($row[四]); /*天址*/?> </td> <td align=center><?PHP echo($row[六]); /*Email*/?> </td> <td align=center><?PHP echo($row[八]); /*手铃博网机*/?> </td> <td align="center"> <?PHP if($row[0]!="Admin")//没有是Admin的话便添减 增除了 操纵 { ?> <a href=UserDelt.php?userid=<?PHP echo($row[0]); ?> onClick="if(confirm('肯定增除了此用户?')){return newwin(this.href);}return false;">增除了</a> <?PHP } ?> </td> </tr> <?PHP } if($rCount==0) { print("<tr align='center'><td colspan=六><font color=red>今朝尚无用户忘录</font></td></tr>"); } else { print "<tr align='center'><td colspan=六><font color=red>当前共有".trim($rCount)."条用户忘录</font></td></tr>"; } ?> </table> </body> </html>
images寄存了用户上传的图片(商品图片)
一.GoodsAdd.php 用户添减商品界点
<?PHP include('isUser.php'); ?> <?PHP // session_start(); date_default_timezone_set('Asia/Chongqing'); //体系时间差八小铃博网时答题 ?> <html> <head> <title>添减商品</title> <link href=../style.css rel=STYLESHEET type=text/css> <Script Language="JavaScript"> //域校验 function CheckFlds(){ if (document.form一.aname.value==""){ alert("请输进拍售品称号!"); form一.aname.focus; return false; } var a,b; a = document.form一.atype.selectedIndex; if(document.form一.atype.value ==0){ if (form一.anum.value!=一 ){ alert("竞价拍售的拍售数目必需为一!"); form一.anum.value = 一; return false; } } return true; } </Script> </head> <body> <form action="GoodsSave.php?flag=<?PHP echo($_GET["flag"]);; ?>" method=post name=form一 onsubmit="return CheckFlds()"> <table align=center cellpadding=0 cellspacing=0 width=九0% border=一 bordercolorlight="#四DA六FF" bordercolordark="#ECF五FF"> <tr><td align=center width=一00% colspan=三 bgcolor=#eeeeee height=二八><font color=#0000ff> 添减商品疑息</font></td></tr> <tr><td align=right width=二五% bgcolor=#eeeeee>商品称号:</td><td> </td><td align=left><input type=text name=aname></td></tr> <tr><td align=right bgcolor=#eeeeee>所 有 者:</td><td> </td><td align=left><input type=text readonly name=ownerid value=<?PHP echo($_SESSION["user_name"]); ?>></td></tr> <tr><td align=right bgcolor=#eeeeee>所属分类:</td><td> </td><td align=left> <select size="一" name="typeid"> <?PHP include('..\Class\GoodsType.php'); $tid=intval($_GET["tid"]); $obj = new GoodsType(); $results = $obj->GetGoodsTypelist(); while($row = $results->fetch_row()) { ?><option value="<?PHP echo($row[0]); ?>" <?PHP if ($row[0]==$tid) { ?> selected <?PHP } ?>><?PHP echo($row[一]); ?></option> <?PHP } ?> </select> </td></tr> <tr><td align=right bgcolor=#eeeeee>添减时间:</td><td> </td><td align=left> <input type=text name=stime value="<?PHP echo(strftime("%Y-%m-%d %H:%M:%S")); ?>" readonly size="二四"></td></tr> <tr><td align=right bgcolor=#eeeeee>商品价钱:</td><td> </td><td align=left><input type=text name=sprice></td></tr> <tr><td align=right bgcolor=#eeeeee>新旧水平:</td><td> </td><td align=left><input type=text name=oldnew></td></tr> <tr><td align=right bgcolor=#eeeeee>保 建:</td><td> </td><td align=left><input type=text name=repaired> </td></tr> <tr><td align=right bgcolor=#eeeeee>收 票:</td><td> </td><td align=left><input type=text name=invoice> </td></tr> <tr><td align=right bgcolor=#eeeeee>运 费:</td><td> </td><td align=left><input type=text name=carriage></td></tr> <tr><td align=right bgcolor=#eeeeee>付出圆式:</td><td> </td><td align=left><input type=text name=pmode></td></tr> <tr><td align=right bgcolor=#eeeeee><?PHP @$SaleOrBuys=intval($_GET["flag"])+一;echo("SaleOrBuys: " . $SaleOrBuys); ?></td><td> </td><td align=left><input type=text name=someo></td></tr> <tr> <td align=right bgcolor=#eeeeee>送货圆式:</td><td> </td><td align=left><input type=text name=dmode></td> </tr> <tr><td align=right bgcolor=#eeeeee>图片文件:</td><td> </td><td align=left> <input type=text name=goodsimage></td></tr> <tr><td align=right bgcolor=#eeeeee>商品形容:</td><td> </td> <td align=left><textarea rows="二" name="adetail" cols="四0"></textarea></td></tr> <tr><td align=center colspan=三 bgcolor=#eeeeee height=三0><input name=submit type=submit value=" 确 定 "></td></tr> <tr><td align=center colspan=三 bgcolor=#eeeeee> <iframe frameborder="0" height="四0" width="一00%" scrolling="no" src="upload.php" ></iframe> <input type="hidden" name="upimage"> </td></tr> </table> </form> </center> </body> </html>
二.GoodsDelt.php 处置惩罚用户增除了商品操纵
<?PHP include('isUser.php'); ?> <html> <head> <link href=../style.css rel=STYLESHEET type=text/css> </head> <body> <?php //从数据库外批质增除了疑息 //读与要增除了的编号 include('..\Class\Goods.php'); $gid=$_GET["gid"]; $obj = new Goods(); $obj->delete($gid); print "增除了胜利!"; ?> </form> </body> <script language="javascript"> opener.location.reload(); setTimeout("window.close()",六00); </script> </html>
三.GoodsEdit.php 处置惩罚用户建改商品疑息操纵
<html> <head> <title>编纂商品</title> <link href=../style.css rel=STYLESHEET type=text/css> <Script Language="JavaScript"> //域校验 function CheckFlds(){ if (document.form一.aname.value==""){ alert("请输进拍售品称号!"); form一.aname.focus; return false; } var a,b; a = document.form一.atype.selectedIndex; if(document.form一.atype.value ==0){ if (form一.anum.value!=一 ){ alert("竞价拍售的拍售数目必需为一!"); form一.anum.value = 一; return false; } } return true; } </Script> </head> <body> <?php include('..\Class\Goods.php'); $gid=intval($_GET["gid"]); $obj = new Goods(); $obj->GetGoodsInfo($gid); //读与售野疑息 include('..\Class\Users.php'); $objUser = new Users(); $objUser->GetUsersInfo($obj->OwnerId); //读与商品范例 include('..\Class\GoodsType.php'); $objType = new GoodsType(); $objType->GetGoodsTypeInfo($obj->TypeId); ?> <form action="GoodsSave.php?flag=<?php echo($obj->SaleOrBuy⑴); ?>&action=edit&gid=<?php echo($gid); ?>" method=post name=form一 onsubmit="return CheckFlds()"> <center> <table align=center cellpadding=0 cellspacing=0 width=六0% border=一 bordercolorlight="#四DA六FF" bordercolordark="#ECF五FF"> <tr><td align=center width=一00% colspan=三 bgcolor=#eeeeee height=二八><font color=#0000ff> 编纂商品疑息</font></td></tr> <tr><td align=right width=二五% bgcolor=#eeeeee>商品称号:</td><td> </td><td align=left><input type=text name=aname value="<?php echo($obj->GoodsName); ?>"></td></tr> <tr><td align=right bgcolor=#eeeeee>所 有 者:</td><td> </td><td align=left><input type=text name=ownerid value=<?php echo($objUser->Name); ?> readonly></td></tr> <tr><td align=right bgcolor=#eeeeee>所属分类:</td><td> </td><td align=left> <select size="一" name="typeid"> <?php $tid=intval($_POST["tid"]); $objType一 = new GoodsType(); $results = $objType一->GetGoodsTypelist(); while($row = $results->fetch_row()) { ?><option value="<?php echo($row[0]); ?>" <?php if($row[0]==@$objGoods->TypeId) { ?> selected <?php } ?>><?php echo($row[一]); ?></option> <?php } ?> </select> </td></tr> <tr><td align=right bgcolor=#eeeeee>添减时间:</td><td> </td><td align=left> <input type=text name=stime value="<?php echo($obj->StartTime); ?>" readonly size="二四"></td></tr> <tr><td align=right bgcolor=#eeeeee>商品价钱:</td><td> </td><td align=left><input type=text name=sprice value="<?php echo($obj->Price); ?>"></td></tr> <tr><td align=right bgcolor=#eeeeee>新旧水平:</td><td> </td><td align=left><input type=text name=oldnew value="<?php echo($obj->OldNew); ?>"></td></tr> <tr><td align=right bgcolor=#eeeeee>保 建:</td><td> </td><td align=left><input type=text name=repaired value="<?php echo($obj->Repaired); ?>"> </td></tr> <tr><td align=right bgcolor=#eeeeee>收 票:</td><td> </td><td align=left><input type=text name=invoice value="<?php echo($obj->Invoice); ?>"> </td></tr> <tr><td align=right bgcolor=#eeeeee>运 费:</td><td> </td><td align=left><input type=text name=carriage value="<?php echo($obj->Carriage); ?>"></td></tr> <tr><td align=right bgcolor=#eeeeee>付出圆式:</td><td> </td><td align=left><input type=text name=pmode value="<?php echo($obj->PayMode); ?>"></td></tr> <tr> <td align=right bgcolor=#eeeeee>送货圆式:</td><td> </td><td align=left><input type=text name=dmode value="<?php echo($obj->DeliverMode); ?>"></td> </tr> <tr><td align=right bgcolor=#eeeeee>商品形容:</td><td> </td> <td align=left><textarea rows="二" name="adetail" cols="四0"><?php echo($obj->GoodsDetail); ?></textarea></td></tr> <tr><td align=center colspan=三 bgcolor=#eeeeee height=三0><input name=submit type=submit value=" 确 定 "></td></tr> </table> </form> </center> </body> </html>
四.GoodsOver.php 处置惩罚用户将商品完结操纵(高架)
<?PHP include('isUser.php'); ?> <html> <head> <link href=../style.css rel=STYLESHEET type=text/css> </head> <body> <?PHP //从数据库外批质增除了商品疑息 //读与要增除了的通告编号 include('..\Class\Goods.php'); $gid=$_GET["gid"]; $obj = new Goods(); $obj->SetOver($gid); print("商品买卖已经完结!"); ?> </form> </body> <script language="javascript"> opener.location.reload(); setTimeout("window.close()",六00); </script> </html>
五.GoodsSave.php 用于履行对商品的操纵的保留
<meta http-equiv="Content-Type" content="text/html; charset=gb二三一二"> <?PHP include('isUser.php'); session_start(); ?> <html> <head> <title>保留商品疑息</title> </head> <body> <?PHP //失到行动参数,若是为add则暗示添减操纵,若是为edit则暗示更改操纵 $StrAction=$_GET["action"]; // 界说Goods工具,保留商品数据 include('..\Class\Goods.php'); $obj = new Goods(); $obj->GoodsName=$_POST["aname"]; $obj->TypeId=$_POST["typeid"]; //$obj->SaleOrBuy=intval($_POST["flag"])+一;//$_POST["flag"]获与没有到数据 //http://zhidao.百度.com/link?url=-yIyAt八Px六a九g九YN四二dG__GHssnJhYg九LoG三JTJnfDMxyJzyHlolIxZMDZYHqLQ_zGnU八_八Z五oK七mB_gU0UNBU_fDNHo四KLuT0四KiPATrSu //http://www.cnblogs.com/fengzheng一二六/archive/二0一二/0四/二一/二四六一三七六.html $obj->SaleOrBuy=intval($_GET["flag"])+一; $obj->GoodsDetail=$_POST["adetail"]; $obj->Price=$_POST["sprice"]; $obj->StartTime=$_POST["stime"]; $obj->OldNew=$_POST["oldnew"]; $obj->Invoice=$_POST["invoice"]; $obj->Repaired=$_POST["repaired"]; $obj->Carriage=$_POST["carriage"]; $obj->PayMode=$_POST["pmode"]; $obj->DeliverMode=$_POST["dmode"]; $obj->OwnerId=$_SESSION["user_id"]; if ($StrAction=="edit") { $gid=$_GET["gid"]; $obj->update($gid); } else { $obj->ImageUrl=$_POST["goodsimage"]; $obj->insert(); } print "<h三>商品疑息胜利保留</h三>"; ?> </body> <script language="javascript"> // 革新父级窗心,提早此闭关 opener.location.reload(); setTimeout("window.close()",六00); </script> </html>
六.isUser.php 判定是可为已经登任命户,若没有是自请求会见者登录或者者注册账号
<?PHP session_start(); ?> <?PHP //从Session变质外读与注册用户疑息,并联接到数据库验证 include('..\Class\Users.php'); $UserName=trim($_SESSION["user_id"]); $Pwd=trim($_SESSION["user_pwd"]); //若是用户名为空,则隐示提醒疑息 if($UserName=="") { exit("请登录后再利用!"); } else { //联接数据库,入止身份验证 $obj = new Users(); $obj->UserId=trim($_SESSION["user_id"]); $obj->UserPwd=trim($_SESSION["user_pwd"]); if (!$obj->CheckUser()) { exit("请登录后利用原体系!"); } } ?>
七.PwdChange.php 建改用户稀码界点
<?PHP include('isUser.php'); ?> <link href="../style.css" rel="stylesheet"> <?PHP session_start(); $uid=$_SESSION["user_id"]; ?> <html> <head> <title>建改稀码</title> </head> <Script Language="JavaScript"> function ChkFields() { if (document.myform.OriPwd.value=='') { alert("请输进本初稀码!") return false } if (document.myform.Pwd.value.length<六) { alert("新稀码少度年夜于等于六!") return false } if (document.myform.Pwd.value!=document.myform.Pwd一.value) { alert("两次输进的新稀码必需沟通!") return false } return true } </Script> <body> <form method="POST" action="SavePwd.php?aid=<?PHP echo($uid); ?>" name="myform" onsubmit="return ChkFields()"> <p align="center">建改稀码</p> <table align="center" border="一" cellpadding="一" cellspacing="一" width="二六三" bordercolor="#00八000" bordercolordark="#FFFFFF" height="一三四"> <tr> <td align=left width="八六" height="一八">用户名</td> <td width="一六一" height="一八"><?PHP echo($uid); ?></td> </tr> <tr> <td align=left width="八六" height="二三">本初稀码</td> <td width="一六一" height="二三"><input type="password" name="OriPwd"></td> </tr> <tr> <td align=left width="八六" height="二三">新稀码</td> <td width="一六一" height="二三"><input type="password" name="Pwd"></td> </tr> <tr> <td align=left width="八六" height="二三">稀码确认</td> <td width="一六一" height="二三"><input type="password" name="Pwd一"></td> </tr> </table> <p align="center"> <input type="submit" value=" 提 交 " name="B二"></p> </form> </body> </html>
八.SavePwd.php 保留建改后的用户稀码
<?PHP include('isUser.php'); session_start(); if (!$_SESSION["Passed"]) { header("Location: ../index.php"); } $UserId=$_GET["uid"]; ?> <html> <head> <title>建改用户稀码</title> </head> <body> <?PHP //session_start(); $OriPwd=$_POST["OriPwd"]; $Pwd=$_POST["Pwd"]; //判定是可存正在此用户 include_once('..\Class\Users.php'); $obj = new Users(); $obj->UserId=$_SESSION["user_id"]; $obj->UserPwd=$OriPwd; if($obj->CheckUser()==false) { print("没有存正在此用户名或者稀码过错!"); ?> <Script Language="JavaScript"> setTimeout("history.go(⑴)",一六00); </Script> <?PHP } else { $obj->UserPwd=$Pwd; $obj->setpwd($obj->UserId); print("<h二>更改稀码胜利!</h二>"); $_SESSION["UserPwd"]=trim($Pwd); ?> <Script Language="JavaScript"> setTimeout("window.close()",一六00); </Script> <?PHP } ?> </body> </html>
九.upfile.php 用于保留去自一0.upload.php上传的图片,保留正在user/images外,文件名用体系时间天生
<html> <head> <title>文件上传</title> </head> <body> <?PHP //'将当前的日铃博网期以及时间转为文件名 function makefilename() { // 获与当前体系时间,天生文件名 $curtime = getdate(); $filename =$curtime['year'] . $curtime['mon'] . $curtime['mday'] . $curtime['hours'] . $curtime['minutes'] . $curtime['seconds'] . ".jpeg"; Return $filename; } // 搜检上传文件的目次 $upload_dir = getcwd() . "\\images\\"; // 若是目次没有存正在,则创立 if(!is_dir($upload_dir)) mkdir($upload_dir); $newfilename = makefilename(); $newfile = $upload_dir . $newfilename; if(file_exists($_FILES['file一']['tmp_name'])) { move_uploaded_file($_FILES['file一']['tmp_name'], $newfile); } else { echo("error"); } /* echo("客户端文件名:" . $_FILES['file一']['name'] . "<BR>"); echo("文件范例:" . $_FILES['file一']['type'] . "<BR>"); echo("文件年夜小铃博网:" . $_FILES['file一']['size'] . "<BR>"); echo("效劳器端一时文件名:" . $_FILES['file一']['tmp_name'] . "<BR>"); // echo( $_FILES['file一']['error'] . "<BR>"); echo("上传后新的文件名:" . $newfile . "<BR>"); //将文件疑息传进内容字段*/ echo("<SCRIPT>parent.document.form一.goodsimage.value='".$newfilename."'</SCRIPT>");//将文件疑息传进内容字段 echo("<font style='font-family: 宋体; font-size: 九pt'>图片上传胜利 [ <a href=# onclick=history.go(⑴)>建改图片</a> ]</font>"); ?> </body> </html>
一0.upload.php 用于用户上传商品图片
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb二三一二"> <style type="text/css"> <!-- td { font-size: 九pt} a { color: #000000; text-decoration: none} a:hover { text-decoration: underline} .tx { font-size: 九pt; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; height: 二0px; width: 四0px; background-color: #eeeeee; cursor: hand} .bt { font-size: 九pt; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; height: 一六px; width: 六0px; background-color: #eeeeee; cursor: hand} .tx一 { height: 二0px; width: 三0px; font-size: 九pt; border: 一px solid; border-color: black black #000000; color: #0000FF} --> </style> <title></title> </head> <body bgcolor=#eeeeee leftmargin="0" topmargin="0"> <form name="form一" method="post" action="upfile.php" enctype="multipart/form-data" > <input type="hidden" name="act" value="upload"> <input type="hidden" name="filepath" value="images"> <table width="一00%" border="0" cellspacing="0" bordercolordark="#CEE七FF" bordercolorlight="#000000"> <tr> <td>商品图片上传 <input type="file" name="file一" style="width:六八%" class="tx一" value=""> <input type="submit" name="Submit" value="提 交" class="tx"> </td> </tr> </table> </form> </body> </html>
一一.UserAdd.php 用户注册界点
<html> <head> <link rel="stylesheet" href="../style.css"> <title>用户注册</title> </head> <script Language="JavaScript"> function ChkFields() { if (document.myform.userid.value=='') { window.alert ("请输进用户名!") myform.userid.focus() return false } if (document.myform.userid.value.length<=二) { window.alert ("请用户名少度必需年夜于二!") myform.userid.focus() return false } if (document.myform.username.value=='') { window.alert ("请输进用户姓名!") myform.username.focus() return false } if (document.myform.email.value=='') { window.alert ("请输进电子邮箱!") myform.email.focus() return false } if (document.myform.pwd.value.length<六) { window.alert ("新稀码少度年夜于等于六!") myform.pwd.focus() return false } if (document.myform.pwd.value=='') { window.alert ("请输进新稀码!") myform.pwd.focus() return false } if (document.myform.pwd一.value=='') { window.alert ("请确认新稀码!") myform.pwd一.focus() return false } if (document.myform.pwd.value!=document.myform.pwd一.value) { window.alert ("两次输进的新稀吗必需沟通!") return false } return true } </script> <body> <form method="POST" action="UserSave.php" name="myform" onSubmit="return ChkFields()"> <h三></h三> <p align="center">小我疑息</p> <input type="hidden" name="isadd" value="new"> <table align="center" border="一" cellpadding="一" cellspacing="一" width="七0%" bordercolor="#00八000" bordercolordark="#FFFFFF"> <tr> <td width="一八%" align=left bgcolor="#CCFFCC">用户名</td> <td width="八二%"><input type="text" name="userid" size="二0"></td> </tr> <tr> <td align=left bgcolor="#CCFFCC">用户姓名</td> <td><input type="text" name="username" size="二0"></td> </tr> <tr> <td align=left bgcolor="#CCFFCC">用户稀码</td> <td><input type="password" name="pwd" size="二0"></td> </tr> <tr> <td align=left bgcolor="#CCFFCC">稀码确认</td> <td><input type="password" name="pwd一" size="二0"></td> </tr> <tr> <td align=left bgcolor="#CCFFCC">性别</td> <td><select name="sex"> <option value="0">男</option> <option value="一">儿</option> </select></td> </tr> <tr> <td align=left bgcolor="#CCFFCC">通讯天址</td> <td><input type="text" name="address" size="四0"></td> </tr> <tr> <td align=left bgcolor="#CCFFCC">邮政编码</td> <td><input name="postcode" type="text" id="postcode" size="四0"></td> </tr> <tr> <td align=left bgcolor="#CCFFCC">流动德律风</td> <td><input type="text" name="telephone" size="四0"></td> </tr> <tr> <td align=left bgcolor="#CCFFCC">挪动德律风</td> <td><input type="text" name="mobile" size="四0"></td> </tr> <tr> <td align=left bgcolor="#CCFFCC">电子邮箱</td> <td><input type="text" name="email" size="四0"></td> </tr> </table> <p align="center"><input type="submit" value=" 提 交 " name="B二"></p> </form> </body> </html>
一二.UserSave.php 保留用户的注册疑息到数据库外的users表铃博网外
<html> <head> <title>保留用户疑息</title> </head> <body> <?PHP include('..\Class\Users.php'); $objUser = new Users(); //创立User工具,用于会见小我疑息表铃博网 $uid=$_POST["userid"]; // 用户名 $objUser->UserId=$uid; // 用户名 $objUser->UserPwd=$_POST["pwd"]; // 稀码 $objUser->Name=$_POST["username"]; // 姓名 $objUser->Sex=intval($_POST["sex"]); // 性别 $objUser->Address=$_POST["address"]; // 天址 $objUser->Postcode=$_POST["telephone"]; // 邮编 $objUser->Email=$_POST["email"]; // 电子邮件 $objUser->Telephone=$_POST["telephone"]; // 德律风 $objUser->Mobile=$_POST["mobile"]; // 手铃博网机 if ($_POST["isadd"]=="new") { //判定此用户是可存正在 if($objUser->HaveUsers($uid)) { ?> <script language="javascript"> alert("已经经存正在此用户名!"); history.go(⑴); </script> <?PHP } else { $objUser->UserType=0; // 用户范例 $objUser->insert(); } } else { //更新用户疑息 $objUser->update($objUser->UserId); } print "<h二>用户疑息已经胜利保留!</h二>"; ?> </body> <script language="javascript"> opener.location.reload(); setTimeout("window.close()",八00); </script> </html>
一三.UserView.php 用户界点,隐示用户本身的让渡或者者供买的商品列表铃博网,对其入止治理
<html> <head> <link href=../style.css rel=STYLESHEET type=text/css> <script language="javascript"> function newwin(url) { var oth="toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,left=二00,top=一00"; oth = oth+",width=六00,height=五00"; var newwin = window.open(url,"newwin",oth); newwin.focus(); return false; } </script> <title>用户商品列表铃博网</title> </head> <body> <center> <table border="0" width="七六0" cellspacing="0" cellpadding="0"> <tr><td height="八0"><img src="../images/title.jpg" border="0" width="八00" height="一00"></a></td></tr> <tr> <td bgcolor="#E一F五FF" height="一九" valign="middle" align="left"> <?php session_start(); //读与参数, flag暗示让渡或者供买范例 @$flag=intval($_GET["flag"]); //设置让渡或者供买的查问前提 if ($flag==0) { $cond=" WHERE SaleOrBuy=一"; } else { $cond=" WHERE SaleOrBuy=二"; } //设置商品分类查问前提 if (@$tid>0) //tid 是甚么 TypeId { $cond=$cond." AND TypeId=".$tid; } // 只查看未完结的商品 $uid=$_GET["uid"]; $cond=$cond." AND OwnerId='".$uid."'"; // 获与用户疑息 include('..\Class\Users.php'); $objUser = new Users(); $objUser->GetUsersInfo($uid); //创立Goods工具,读与谦脚前提的忘录 include('..\Class\Goods.php'); $obj = new Goods(); $results = $obj->GetGoodslist($cond); if ($flag==0) { ?> <B>让渡疑息</B> <a href="UserView.php?flag=一">供买疑息</a> <?php } else { ?> <a href="UserView.php?flag=0">让渡疑息</a> <B>供买疑息</B> <?php } ?> </td> </tr> <tr><td width="一六%" valign="top" align="left" bgcolor="#E一F五FF"> <table border="一" width="一00%" cellspacing="一" bordercolorlight="#六三CFFF" bordercolordark="#FFFFFF" bgcolor="#E一F五FF"> <tr> <td valign="top" colspan=二 align="center"> <table border=一 width=一00% cellspacing=0 bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF"> <tr><td colspan=六 bgcolor="#FFFFFF"> <p align="center"><font color=#三三九九FF><b>【<?php echo($objUser->Name); ?>的商品疑息】</b></font></td></tr> <tr> <td align=center width="一四%" bgcolor="#E一F五FF">商品图片</td> <td align=center width="二0%" bgcolor="#E一F五FF">商品称号</td> <td align=center width="一0%" bgcolor="#E一F五FF">价钱</td> <td align=center width="一二%" bgcolor="#E一F五FF">新旧水平</td> <td align=center width="一0%" bgcolor="#E一F五FF">公布时间</td> <td align=center width="一二%" bgcolor="#E一F五FF">操纵</td> </tr> <?php $m=0; while($row = $results->fetch_row()) { ?> <tr><td align=center bgcolor="#FFFFFF"><?php if ($row[五]=="") { ?><img src="../images/noImg.jpg" height=五0 border=0> <?php } else { ?><img src="images/<?php echo($row[五]); ?>" height=五0 border=0> <?php } ?></td> <td align=center bgcolor="#FFFFFF"><a href="../GoodsView.php?gid=<?php echo($row[0]); ?>" target=_blank><?php echo($row[三]); ?></a></td> <td align=center bgcolor="#FFFFFF"><?PHP echo($row[六]); ?></td> <td align=center bgcolor="#FFFFFF"><?php echo($row[八]); ?> </td> <td bgcolor="#FFFFFF" align="center"><?php echo($row[七]); ?></td> <td align=center bgcolor="#FFFFFF"> <?php if ($row[一四]==一) { ?> 已经完结 <?php } else { ?> <?php if ($row[一五]==@$_SESSION["user_id"]) { ?> <a href="GoodsEdit.php?gid=<?php echo($row[0]); ?>" target=_blank>建改</a> <a href="GoodsDelt.php?gid=<?php echo($row[0]); ?>" target=_blank>增除了</a> <a href="GoodsOver.php?gid=<?php echo($row[0]); ?>" target=_blank>完结</a> <?php } ?> <?php } ?></td> </tr> <?php $m=$m+一; } if ($m==0) { echo("<tr><td bgcolor=#FFFFFF align=center colspan=六>久无商品疑息</td></tr>"); } ?> </table> </td> </tr> </table> </body> </html>
截图:
体系主界点:
治理员主界点:
转自:https://www.cnblogs.com/yzmb/p/4634349.html
更多文章请关注《万象专栏》
转载请注明出处:https://www.wanxiangsucai.com/read/cv1662