conn.php
<?php $conn = mysqli_connect("localhost:3306", "root", "123456","db") or die("连接数据库服务器失败!".mysqli_error()); //连接MySQL服务器,选择数据库 mysqli_query($conn,"set names utf8"); //设置数据库编码格式utf8 ?>
gl.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>管理员界面</title> </head> <body> <div align="center"> <a href="gadd.html">添加商品</a><br> <a href="del.php">删除商品</a><br> <a href="update.php">更改商品</a><br> <a href="updd.html">更改订单状态</a><br> </div> </body> </html>
gadd.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>添加商品界面</title> </head> <body> <div align="center" > <form action="gadd.php" method="post"> 书名<input type="text" name="name"><br> 价格<input type="text" name="prince"><br> 数量<input type="text"name="number"><br> <input type="submit" value="确认添加"> </form> </div> </body> </html>
gadd.php
<?php /** * Created by PhpStorm. * User: 田庆辉 * Date: 2020/5/29 * Time: 11:00 */ $name=$_POST['name']; $prince=$_POST['prince']; $number=$_POST['number']; include_once("conn.php"); $sql = "insert into book(name,prince,number) values ('$name','$prince','$number')"; //echo 'sql语句为',$sql; $result = mysqli_query($conn,$sql); //echo $result; if ($result){ echo "添加成功,点击<a href='gl.html'>这里</a>回到主菜单"; }else{ echo "<script>alert('添加失败');history.go(-1);</script>"; }
del.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>删除商品界面</title> <style type="text/css"> html{font-size:12px;} fieldset{width:850px; margin: 0 auto;} legend{font-weight:bold; font-size:14px;} label{float:left; width:70px; margin-left:10px;} .left{margin-left:80px;} .input{width:150px;} .sousu{margin-left:210px; width:300px} .sousubutton{margin-left:20px;} </style> </head> <body> <?php ?> <fieldset> <legend><font color="blue">商品删除</font></legend> <p> <input id="sousu" name="sousu" type="text" class="sousu" > <input type="submit" name="sousubutton" value="搜索" class="sousubutton"> <p/> <table border="0px"cellspacing="20px" cellpadding="5px"> <?php include_once("conn.php"); $sql = "select * from book "; $rs=mysqli_query($conn,$sql); //$row = mysqli_fetch_array($rs); while($row = mysqli_fetch_row($rs)){ echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td><a href='del2.php?id=$row[0]' >删除</a></td><td></td></tr>"; } ?> </table> </fieldset> </body> </html>
del2.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>删除界面</title> </head> <body> </div> </body> </html> <?php include_once("conn.php"); $name=$_GET['id']; echo $name,'商品已经被删除'; $sql = "delete from book where name = '$name'"; //echo 'sql语句为',$sql; $result = mysqli_query($conn,$sql); //echo $result; if ($result){ echo "点击<a href='gl.html'>这里</a>回到主菜单"; }else{ echo "<script>alert('删除失败');history.go(-1);</script>"; }
update.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>修改商品界面</title> <style type="text/css"> html{font-size:12px;} fieldset{width:850px; margin: 0 auto;} legend{font-weight:bold; font-size:14px;} label{float:left; width:70px; margin-left:10px;} .left{margin-left:80px;} .input{width:150px;} .sousu{margin-left:210px; width:300px} .sousubutton{margin-left:20px;} </style> </head> <body> <?php ?> <fieldset> <legend><font color="blue">商品修改</font></legend> <p> <input id="sousu" name="sousu" type="text" class="sousu" > <input type="submit" name="sousubutton" value="搜索" class="sousubutton"> <p/> <table border="0px"cellspacing="20px" cellpadding="5px"> <?php include_once("conn.php"); $sql = "select * from book "; $rs=mysqli_query($conn,$sql); //$row = mysqli_fetch_array($rs); while($row = mysqli_fetch_row($rs)){ echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td><a href='update2.php?id=$row[0]' >修改</a></td><td></td></tr>"; } ?> </table> </fieldset> </body> </html>
update.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>修改界面</title> </head> <body> <div align="center"> 请输入修改后的信息 <form action="" method="post"> 书名<input type="text" name="name" value=<?php echo $_GET['id']?> ><br><br> 价格<input type="text" name="prince"> <br><br> 数量<input type="text" name="number"><br><br> <input type="submit" value="确认修改"> </form> </div> </body> </html> <?php if($_POST) { $name=$_POST['name']; $prince=$_POST['prince']; $number=$_POST['number']; include_once("conn.php"); $sql = "update book set name='$name',prince='$prince',number='$number' where name='$name' "; //echo 'sql语句为',$sql; $result = mysqli_query($conn,$sql); //echo $result; if ($result){ echo "修改成功点击<a href='gl.html'>这里</a>回到主菜单"; echo "<script>alert('修改成功');history.go(-2);</script>"; }else{ echo "<script>alert('修改失败');history.go(-1);</script>"; } }
updateorder.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>修改订单状态界面</title> <style type="text/css"> html{font-size:12px;} fieldset{width:850px; margin: 0 auto;} legend{font-weight:bold; font-size:14px;} label{float:left; width:70px; margin-left:10px;} .left{margin-left:80px;} .input{width:150px;} .sousu{margin-left:210px; width:300px} .sousubutton{margin-left:20px;} </style> </head> <body> <?php ?> <fieldset> <legend><font color="blue">订单修改</font></legend> <p> <input id="sousu" name="sousu" type="text" class="sousu" > <input type="submit" name="sousubutton" value="搜索" class="sousubutton"> <p/> <table border="0px"cellspacing="20px" cellpadding="5px"> <?php include_once("conn.php"); $sql = "select * from orderinfo "; $rs=mysqli_query($conn,$sql); echo "<tr><td>商品名(书名)</td><td>用户名</td><td>地址</td><td>电话号码</td><td>订单状态</td><td>操作</td><td></td></tr>"; //$row = mysqli_fetch_array($rs); while($row = mysqli_fetch_row($rs)){ echo "<tr><td>《$row[3]》</td><td>$row[2]</td><td>$row[1]</td><td>$row[4]</td><td>$row[5]</td><td><a href='updateorder2.php?id=$row[0]' >修改订单状态</a></td><td></td></tr>"; } ?> </table> </fieldset> </body> </html>
updaterorder2.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>修改界面</title> </head> <body> <div align="center"> 请输入修改后的信息 <form action="" method="post"> 订单号<input type="text" name="name" value=<?php echo $_GET['id']?> ><br><br> 订单状态<select name="state"> <option value ="未发货">未发货</option> <option value ="已发货">已发货</option> <option value="用户已经接收货物">用户已经接收货物</option> </select><br><br> <input type="submit" value="确认修改"> </form> </div> </body> </html> <?php if($_POST) { $state=$_POST['state']; $id=$_POST['name']; include_once("conn.php"); $sql = "update orderinfo set state='$state' where num=$id "; //echo 'sql语句为',$sql; $result = mysqli_query($conn,$sql); //echo $result; if ($result){ echo "修改成功点击<a href='gl.html'>这里</a>回到主菜单"; echo "<script>alert('修改成功');history.go(-2);</script>"; }else{ echo "<script>alert('修改失败');history.go(-1);</script>"; } }
addorder.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>添加订单界面</title> </head> <body> <div align="center" > <form action="" method="post"> 商品名<input type="text"name="goods"><br> 用户名<input type="text" name="username"><br> 收货地址<input type="text" name="address"><br> 电话号码<input type="text" name="phone"><br> <input type="submit" value="确认添加"> </form> </div> </body> </html> <?php if($_POST) { $goods=$_POST['goods']; $username=$_POST['username']; $address=$_POST['address']; $phone=$_POST['phone']; include_once("conn.php"); $sql = "insert into orderinfo(goods,username,address,phone,state) values ('$goods','$username','$address','$phone','未发货')"; //echo 'sql语句为',$sql; $result = mysqli_query($conn, $sql); //echo $result; if ($result) { echo "<script>alert('修改成功');history.go(-2);</script>"; } else { echo "<script>alert('添加失败');history.go(-1);</script>"; } }
seeorder.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>查看订单界面</title> <style type="text/css"> html{font-size:12px;} fieldset{width:850px; margin: 0 auto;} legend{font-weight:bold; font-size:14px;} label{float:left; width:70px; margin-left:10px;} .left{margin-left:80px;} .input{width:150px;} .sousu{margin-left:210px; width:300px} .sousubutton{margin-left:20px;} </style> </head> <body> <?php ?> <fieldset> <legend><font color="blue">订单详情查看</font></legend> <p> <input id="sousu" name="sousu" type="text" class="sousu" > <input type="submit" name="sousubutton" value="搜索" class="sousubutton"> <p/> <table border="0px"cellspacing="20px" cellpadding="5px"> <?php include_once("conn.php"); $sql = "select * from orderinfo "; $rs=mysqli_query($conn,$sql); //$row = mysqli_fetch_array($rs); echo "<tr><td>商品名(书名)</td><td>用户名</td><td>地址</td><td>电话号码</td><td>订单状态</td><td></td><td></td></tr>"; while($row = mysqli_fetch_row($rs)){ echo "<tr><td>《$row[1]》</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td><td>$row[5]</td><td></td><td></td></tr>"; } ?> </table> </fieldset> </body> </html>