1 系统背景及意义
1.1系统开发背景介绍
餐饮业在我国有着悠久的发展历史,是与人民生活密切相关的 行业之一,同时也是我国经济增长的新亮点,在 2010 年全国餐饮零 售总额高达 15913 亿元,实际增长约 14.3。在信息系统相对普及的 今天,餐饮行业的普及率却不容乐观。尽管有许多大型的餐厅配备了相对完善的点餐系统。但是许许多多的中小型餐厅依旧停留在纸 笔点餐的时代,纸笔点餐有效率低下、人力资源占用大、错误率高、 容易引起高峰期点餐客人的不满情绪等缺点。
1.2 系统开发的意义
如果融入智能的点餐管理系统,不仅能对收支状况、原料管理和员工管理上进行合理的 规划,还能加入会员管理功能,做好客户关系管理。
该系统主要包括用户登录及验证、菜单管理、删除菜品、订单管理、修改订单状态等功能
通过对现代点餐系统的升级改良,提供更加快捷的便民服务,使人们的消费过程更加简单方便,增加客人消费的娱乐性,便消费者更能享受出门享受美食的快感。本系统的目标是实现点菜系统所需的各种基本功能,用户可通过访问我们的订餐系统,进行登陆或注册,获得你想要的各种食物,管理员可以查看用户菜品,可以对菜品进行增删改查。
2.系统的设计思路
2.1 数据库设计分析

总共设计了三张数据表
第一张数据表menu为商家菜单,里面有四列,分别是id值,菜品的名称name,菜品的价格price,菜品的描述content。
第二张数据表order为客户所点的菜的菜单,里面有三列,分别是id值,客户所点的菜的名称name与每个菜的单价price
第三张数据表tb_user为管理员注册登录表,;里面有三列,分别是管理员名字user_name,管理员密码user_pwd,管理员电话号码user_tel
2.2 功能模块设计分析
(1)首先是管理员进行登录,若是有账号密码的话直接登录,没有账号密码的话要进行注册,然后再登录。
(2)登录成功的话就正式进入点菜系统了,展示商家所拥有的菜品,但同时也可以进行新菜品供客户选择,商家也可以进行对菜品的删除与添加。
(3)客户选择好菜品之后,所有的信息将直接罗列到订单里,客户不仅可以看到自己所点的所有菜品名称也可以看到总价。
(4)在订单表中,客户不仅可以删除自己不喜欢的单个菜品,也可以删除订单里所有的菜品,然后进行重新选择菜品。
3.程序功能测试及截图
3.1程序代码测试
添加用户界面(add.php)
<?php
//判断session是否存在
session_start();
if (isset($_SESSION['name'])){
    //1.判断数据库是否连接成功
include_once "sqlcon.php";
$name=$_GET['name'];
$price=$_GET['price'];
//2.设置默认编码方式
mysqli_set_charset($conn,'utf-8');
$result = mysqli_query($conn,"insert into `order`(`name`, price) values ('{$name}','$price')");
echo $result;
}else{
    echo "<script>alert('请重新登录')</script>";
    header("refresh:1;url=login_pwd.php");
}添加菜品页面(addMenu.php)
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>添加菜品</title>
</head>
<body>
<div class="box">
    <div class="top">添加菜品</div>
    <form>
        <input type="text" name="name" placeholder="菜品名字" class="text">
        <input type="text" name="price" placeholder="菜品价格" class="text">
        <input type="text" name="content1" placeholder="菜品描述" class="text">
        <input type="button" value="保存" class="submit" onclick="save()">
    </form>
</div>
<style type="text/css">
    body {
        padding: 0px;
        margin: 0px;
        background-image: radial-gradient( #c0fff0, #afcdee,deepskyblue,greenyellow);
    }
    .box {
        width: 250px;
        height: 500px;
        margin: 100px auto;
        border-radius: 15px;
        padding: 0 50px;
        background-color: #99FF99;
    }
    .top {
        font-size: 35px;
        line-height: 120px;
        text-align: center;
        font-family: 华文楷体;
        font-weight: bolder;
    }
    .text {
        width: 100%;
        border: 0px;
        border-bottom: 1px solid black;
        font-size: 20px;
        margin-bottom: 30px;
        outline: none;
        font-family: 华文楷体;
    }
    .submit {
        width: 100%;
        font-size: 25px;
        background-image: linear-gradient(to right, paleturquoise, pink);
        border: 0px;
        font-family: 华文楷体;
        color: white;
        margin-top: 10px;
        cursor: pointer;
    }
    .bottom {
        font-size: 20px;
        line-height: 100px;
        text-align: center;
        font-family: 华文楷体;
    }
    .expire {
        font-family: 华文楷体;
        font-size: 18px;
        cursor: pointer;
    }
</style>
<script type="text/javascript">
    function save() {
        var name = document.getElementsByName('name')[0].value;
        var price = document.getElementsByName('price')[0].value;
        var content1 = document.getElementsByName('content1')[0].value;
        if (!name) {
            alert("请你输入菜品名称");
            return false;
        }
        if (!price) {
            alert("请你输入菜品价格");
            return false;
        }
        if (!content1) {
            alert("请你输入菜品描述");
            return false;
        }
        http_request = new XMLHttpRequest();
        //设置请求状态和返回处理函数
        http_request.onreadystatechange = function () {
            if (http_request.status = 200 && http_request.readyState == 4) {
                if (http_request.responseText == 'success') {
                    //服务器返回结果展示id=result的div程中
                    location.href = 'list.php'
                } else {
                    alert(http_request.responseText);
                }
            }
        }
        //发送http请求
        http_request.open("GET", "saveMenu.php?name="
            + name + "&price=" + price + "&content1=" + content1);
        http_request.send();
    }
</script>
</body>
</html>
删除单个菜品(delete.php)
<?php
include_once "sqlcon.php";
$id=$_GET['id'];
mysqli_query($conn,"delete from menu where id=$id");
删除所有菜品(delete_all.php)
<?php
//判断session是否存在
session_start();
if (isset($_SESSION['name'])){
    //1.判断数据库是否连接成功
    include_once "sqlcon.php";
//2.设置默认编码方式
    mysqli_set_charset($conn,'utf-8');
    $result = mysqli_query($conn,"delete from `order`");
    if ($result){
        echo "<script>alert('清空成功')</script>";
        header("refresh:1;url=order.php");
    }
    else{
        echo "<script>alert('清空失败')</script>";
        header("refresh:1;url=order.php");
    }
}else{
    echo "<script>alert('请重新登录')</script>";
    header("refresh:1;url=login_pwd.php");
}删除最终菜单菜品(delete_order.php)
<?php
include_once "sqlcon.php";
$id=$_GET['id'];
$request = mysqli_query($conn,"delete from `order` where id=$id");
echo $request;首页(index.php)
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<div class="hea">
    点菜系统
</div>
<div >
    <a href="list.php" >菜单管理</a>
</div>
    <a href="order.php">订单管理</a>
</div>
<style type="text/css">
    body{
        padding: 0px;
        margin: 0px;
        background-image: linear-gradient(to bottom,#c0fff0, #afcdee, #350080);
        display: flex;
        height: 100vh;
        justify-content: center;
        align-items: center;
    }
    .hea {
        position: absolute;
        top: 20px;
        width: 600px;
        height: 100px;
        background-image:radial-gradient(deeppink,red,blue,greenyellow);
        text-align: center;
        font-size: 50px;
        line-height: 100px;
        font-family: 华文楷体;
    }
    a:first-child{
        background-color: pink ;
    }
    a{
        background-color: gold;
        width: 250px;
        height: 350px;
        display: inline-block;
        border-radius:15px ;
        margin-right: 30px;
        font-family: 华文楷体;
        font-size: 30px;
        color: black;
        text-align: center;
        line-height: 350px;
        text-decoration: none;
    }
    a:hover{
        font-size: 35px;
        font-family: 华文楷体;
        color: white;
        cursor: pointer;
    }
</style>
</body>
</html>
选菜页面(list.php)
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body onload="search(1)">
<div class="box">
    <div class="header">
       我的菜单
    </div>
        <div class="top">
            <input type="text" name="text" class="text" id="text">
            <span class="btn" onclick="search(1)">查询</span>
            <span class="btn" onclick="addMenu()">添加</span>
            <span class="btn" onclick="back()">返回首页</span>
        </div>
    <div id="result"> </div>
</div>
    <script type="text/javascript">
        function search(page){
            //获取文本框内容
            var text=document.getElementById("text").value;
            //使用Ajax实现查询功能
            //初始化XMLHttpRequest对象
            http_request=new XMLHttpRequest();
            //设置请求状态和返回处理函数
            http_request.onreadystatechange=function (){
                if(http_request.status=200&&http_request.readyState==4){
                    //服务器返回结果展示id=result的div程中
                   document.getElementById("result").innerHTML=http_request.responseText;
                }
            }
            //发送http请求
            http_request.open("GET","search.php?text="+text+"&page="+page);
            http_request.send();
        }
        function order(name, price){
            //初始化XMLHttpRequest对象
            http_request=new XMLHttpRequest();
            //设置请求状态和返回处理函数
            http_request.onreadystatechange=function (){
                if(http_request.status=200&&http_request.readyState==4){
                    let result = http_request.responseText
                    if (result){
                        alert('添加成功');
                    }else{
                        alert('添加失败');
                    }
                }
            }
            //发送http请求
            http_request.open("GET","add.php?name="+name+"&price="+price);
            http_request.send();
        }
        function back() {
            location.href='index.php';
        }
        function addMenu(){
            location.href='addMenu.php';
        }
       function del(id,name){
            if (confirm("确定要删除'"+name+"'吗?")){
                http_request=new XMLHttpRequest();
                //设置请求状态和返回处理函数
                http_request.onreadystatechange=function (){
                    if(http_request.status=200&&http_request.readyState==4){
                        search(1);
                    }
                }
                //发送http请求
                http_request.open("GET","delete.php?id="+id);
                http_request.send();
            }
       }
    </script>
    <style type="text/css">
        body{
            text-align: center;
            padding: 0px;
            margin: 0px;
            background-image: linear-gradient(to bottom,#c0fff0, #afcdee, #350080);
            display: flex;
            height: 100vh;
            justify-content: center;
            align-items: center;
        }
        .box{
            width: 800px;
            height: 600px;
            background-color: #caeeee;
            border-radius: 15px;
            padding: 10px;
        }
        .header{
            font-family: 华文楷体;
            font-size: 30px;
            color: mediumspringgreen;
            text-align: center;
            height: 30px;
            line-height: 30px;
            border-bottom: 1px solid #2e57e0;
            padding: 10px;
        }
        .top{
            text-align: right;
            padding: 10px;
            display: inline-block;
        }
        .text{
            width: 200px;
            height: 25px;
            border-radius: 10px;
        }
        .btn{
            width: 100px;
            height: 25px;
            text-align: center;
            line-height: 25px;
            border:1px solid black;
            display: inline-block;
            margin-left: 10px;
            cursor: pointer;
            border-radius: 10px;
        }
        .btn:hover{
            background-color: #62bed5;
            color: white;
            border:1px solid #62bed5 ;
        }
        .center{
            height: 450px;
            overflow-y:auto ;
            overflow-x: auto;
        }
        table{
            width: 100%;
            border-collapse: collapse;
        }
        th{
            height: 50px;
            line-height: 50px;
        }
        td{
            height: 50px;
        }
        .bottom{
            text-align: right;
            padding-top: 10px;
        }
        .bottom span{
            width: 20px;
            height: 25px;
            text-align: center;
            line-height: 25px;
            border: 1px solid black;
            display: inline-block;
            cursor: pointer;
            margin-left: 10px;
            border-radius: 5px;
        }
        .bottom span:hover {
            background-color: #62bed5;
            color: white;
            border: 1px solid #62bed5;
        }
        .active{
            background-color: #62bed5;
            color: white;
            border: 1px solid #62bed5;
        }
    </style>
</body>
</html>
登录界面(login_pwd.php)
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录界面</title>
</head>
<body>
<div class="box">
    <div class="top">登录</div>
    <form method="post" action="user_login.php" name="form">
        <input type="text" name="user" placeholder="用户名" class="text" value="<?php
        echo empty($_COOKIE['name']) ? " " : $_COOKIE['name'] ?>">
        <input type="password" name="pwd" placeholder="密码" class="text" value="<?php
        echo empty($_COOKIE['pwd']) ? " " : $_COOKIE['pwd'] ?>">
        <input type="checkbox" name="expire" value="7" id="expire" class="expire"> <label for="expire">记住密码</label>
        <input type="button" value="提交" class="submit" onclick="sub()">
    </form>
    <div class="bottom">
        没有帐户?<a href="register.php">注册</a>
    </div>
</div>
<style type="text/css">
    body {
        padding: 0px;
        margin: 0px;
        background-image: linear-gradient(to right, #c0fff0, #afcdee);
    }
    .box {
        width: 250px;
        height: 500px;
        background-color: #ffffff;
        margin: 100px auto;
        border-radius: 15px;
        padding: 0 50px;
    }
    .top {
        font-size: 35px;
        line-height: 220px;
        text-align: center;
        font-family: 华文楷体;
        font-weight: bolder;
    }
    .text {
        width: 100%;
        border: 0px;
        border-bottom: 1px solid black;
        font-size: 20px;
        margin-bottom: 30px;
        outline: none;
        font-family: 华文楷体;
    }
    .submit {
        width: 100%;
        font-size: 25px;
        background-image: linear-gradient(to right, paleturquoise, pink);
        border: 0px;
        font-family: 华文楷体;
        color: white;
        margin-top: 10px;
        cursor: pointer;
    / / 变成小手
    }
    .bottom {
        font-size: 20px;
        line-height: 100px;
        text-align: center;
        font-family: 华文楷体;
    }
    .expire {
        font-family: 华文楷体;
        font-size: 18px;
        cursor: pointer;
</style>
<script type="text/javascript">
    function sub() {
        var user = document.getElementsByName('user')[0].value;
        var pwd = document.getElementsByName('pwd')[0].value;
        if (!user) {
            alert("用户名为空,请你输入用户名");
            return false;
        }
        if (!pwd) {
            alert("密码为空,请你输入密码");
            return false;
        }
        form.submit();
    }
</script>
</body>
</html>
订单页面(order.php)
<style type="text/css">
    body {
        background-image: linear-gradient(180deg, gold, honeydew, greenyellow, orangered, yellow);
    }
    a {
        text-decoration: none;
    }
    </style>
<script type="text/javascript">
    function delete_order(id){
        http_request = new XMLHttpRequest();
        //设置请求状态和返回处理函数
        http_request.onreadystatechange=function (){
            if(http_request.status=200&&http_request.readyState==4){
                location.href = "order.php"
            }
        }
        //发送http请求
        http_request.open("GET", "delete_order.php?id=" + id);
        http_request.send();
        }
</script>
<?php
//判断session是否存在
session_start();
if (isset($_SESSION['name'])){
    //1.判断数据库是否连接成功
    include_once "sqlcon.php";
//2.设置默认编码方式
    mysqli_set_charset($conn,'utf-8');
    $result = mysqli_query($conn,"select * from `order` ");
    $num = 0;//菜品数量
    $total = 0;//总金额
    $i = mysqli_num_rows($result);
    echo <<<str
<table align="center" width="560"  bordercolor="#ACD2DB" bgcolor="#ACD2DB" class="big_td">
    <tr>
        <td width="100" height="10" bgcolor="#DEEBEF">序号</td>
        <td width="100" height="10" bgcolor="#DEEBEF">菜名</td>
        <td width="100" height="10" bgcolor="#DEEBEF">价格</td>
        <td width="100" height="10" bgcolor="#DEEBEF">操作</td>
    </tr>
str;
    if ($i > 0) {
        
        while ($data = mysqli_fetch_assoc($result)) {
            $num += 1;
            $total += $data["price"];
            echo <<<str
    <tr>
        <td width="100" height="25" bgcolor="#DEEBEF">$num</td>
        <td width="100" height="25" bgcolor="#DEEBEF">{$data["name"]}</td>
        <td width="100" height="25" bgcolor="#DEEBEF">{$data["price"]}</td>
        <td width="100" height="25" bgcolor="#DEEBEF"><input type="button" value="删除" onclick="delete_order({$data["id"]})"></td>
    </tr>
str;
        }
    }
    echo <<<str
    <tr>
    <td>总计:</td>
    <td colspan="2">{$total}</td>
    </tr>
    <tr>
    <td colspan="3"><a href="delete_all.php">清空订单</a></td>
    </tr>
     <tr>
    <td colspan="3"><a href="index.php">返回首页</a></td>
    </tr>
</table>
str;
}else{
    echo "<script>alert('请重新登录')</script>";
    header("refresh:1;url=login_pwd.php");
}
注册界面(register.php)
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录界面</title>
</head>
<body>
<div class="box">
    <div class="top">注册</div>
    <form method="post" action="RegisterOk.php" name="form">
        <input type="text" name="user" placeholder="用户名" class="text">
        <input type="password" name="pwd" placeholder="密码" class="text">
        <input type="password" name="pwd1" placeholder="确认密码" class="text">
        <input type="text" name="tel" placeholder="手机号" class="text">
        <input type="button"  value="注册" class="submit" onclick="sub()">
    </form>
    <div class="bottom">
        有帐户?<a href="login_pwd.php">登录</a>
    </div>
</div>
<style type="text/css">
    body{
        padding: 0px;
        margin: 0px;
        background-image: linear-gradient(to right, #c0fff0, #afcdee);
    }
    .box{
        width: 250px;
        height: 500px;
        background-color: #ffffff;
        margin: 100px auto;
        border-radius: 15px;
        padding: 0 50px;
    }
    .top{
        font-size: 35px;
        line-height: 120px;
        text-align: center;
        font-family:华文楷体 ;
        font-weight: bolder;
    }
    .text{
        width: 100%;
        border: 0px;
        border-bottom: 1px solid black;
        font-size: 20px;
        margin-bottom: 30px;
        outline: none;
        font-family:华文楷体 ;
    }
    .submit{
        width: 100%;
        font-size: 25px;
        background-image: linear-gradient(to right,paleturquoise,pink);
        border: 0px;
        font-family:华文楷体 ;
        color: white;
        margin-top: 10px;
        cursor: pointer;//变成小手
    }
    .bottom{
        font-size: 20px;
        line-height: 100px;
        text-align: center;
        font-family:华文楷体;
    }
    .expire{
        font-family: 华文楷体;
        font-size: 18px;
        cursor: pointer;
    }
</style>
<script type="text/javascript">
    function sub(){
        var user = document.getElementsByName('user')[0].value;
        var pwd = document.getElementsByName('pwd')[0].value;
        var pwd1 = document.getElementsByName('pwd1')[0].value;
        var tel = document.getElementsByName('tel')[0].value;
        if (!user){
            alert("用户名为空,请你输入用户名");
            return false;
        }
        if (!pwd){
            alert("密码为空,请你输入密码");
            return false;
        }
        if (!pwd1){
            alert("确认密码为空,请你输入确认密码");
            return false;
        }
        if (pwd!=pwd1){
            alert("两次输入的密码不一致");
            return false;
        }
        if (!tel){
            alert("手机号为空,请你输入手机号");
            return false;
        }
        if (tel.length!=11){
            alert("请输入十一位的手机号");
            return false;
        }
        form.submit();
    }
</script>
</body>
</html>
注册成功界面(RegisterOk.php)
<?php
//1.判断数据库是否连接成功
include_once "sqlcon.php";
//2.设置默认编码方式
mysqli_set_charset($conn,'utf-8');
$user=$_POST['user'];
$pwd=$_POST['pwd'];
$tel=$_POST['tel'];
$result = mysqli_query($conn,"select * from tb_user where user_name ='{$user}'and
 user_pwd='{$pwd}'");
$num = mysqli_num_rows($result);
if ($num > 0){
    echo "<script>alert('用户信息已存在');history.back();</script>";
}
$result1 = mysqli_query($conn,"insert into tb_user(user_name,user_pwd,user_tel)
 values('{$user}','{$pwd}','{$tel}')");
if ($result1==true){
    echo "<script>alert('注册成功')</script>";
    header("refresh:1;url=login_pwd.php");
}else{
    echo "<script>alert('注册失败');history.back();</script>";
}
添加菜品页面(saveMenu.php)
<?php
try {
    //启动session
    session_start();
    if (isset($_SESSION['name'])) {
        //查询课程信息
        include_once "sqlcon.php";
        $name = $_GET["name"];
        $price = $_GET["price"];
        $content1 = $_GET["content1"];
        $result = mysqli_query($conn, "insert into menu(`name`,price,`content`)
value ('{$name}','{$price}','{$content1}')");
        echo "success";
    }
} catch (Exception $e) {
    echo "failure";
}
查找界面(search.php)
<?php
//判断session是否存在
session_start();
if (isset($_SESSION['name'])){
    //1.判断数据库是否连接成功
    include_once "sqlcon.php";
//2.设置默认编码方式
    mysqli_set_charset($conn,'utf-8');
    //获取当前的页码
    $page =intval($_GET["page"]);
    //每一页的记录数(一页中显示几条记录)
    $rows = 7;
    $text=$_GET['text'];
    //获取总记录数(符合条件的记录有多少条)
    $count = mysqli_query($conn,"select count(*) from menu where `name` like'%{$text}%'");
    $total = mysqli_fetch_row($count)[0];
    //获取共多少页进行显示
    $total_page = ceil($total/$rows);
    //显示每一页的记录
    $result= mysqli_query($conn,"select * from menu where `name` like'%{$text}%' limit ".($page-1)*$rows.",".$rows." ");
    echo <<<str
      <div class="center">
        <table border="1">
            <tr>
                <th width="20%">菜品名称</th>
                <th width="58%">菜品描述</th>
                <th width="10%">菜品价格</th>
                <th width="12%">加入订单</th>
            </tr>
str;
    while ($data = mysqli_fetch_assoc($result)){
        echo "<tr>";
        echo "<td>".$data['name']."</td>";
        echo "<td>".$data['content']."</td>";
        echo "<td>".$data['price']."</td>";
        echo "<td>"."<input type='button' value='删除'
        onclick='del(".$data['id'].",\"".$data['name']."\")'>"."<input type='button' value='购买'
        onclick='order(\"".$data['name']."\",\"".$data['price']."\")'>"."</td>";
        echo "</tr>";
    }
    echo <<<str
      </table>
         </div>
           <div class="bottom">
str;
       echo "<span onclick='search(1)'><</span>";
       for ($i=1;$i<=$total_page;$i++){
           echo "<span class='".($page==$i?"active":"")."' onclick='search(".$i.")'>$i</span>";
       }
       echo "<span onclick='search(".$total_page.")'>></span>";
       echo "</div>";
}else{
    echo "<script>alert('请重新登录')</script>";
    header("refresh:1;url=login_pwd.php");
}
连接数据库(sqlcon.php)
<?php
$conn=mysqli_connect("127.0.0.1","root","yjh",
    "userdb","3306");
if($conn==false){
    echo"数据库没有连接成功";
    exit(0);
    //die("数据库没有连接成功");
}
?>
七天免登录(user_login.php)
<?php
//判断是否选中七天免登录
$expire =empty($_POST['expire'])?-1:intval($_POST['expire']);
//1.判断数据库是否连接成功
include_once "sqlcon.php";
//2.设置默认编码方式
$user=$_POST['user'];
$pwd=$_POST['pwd'];
mysqli_set_charset($conn,'utf-8');
$result = mysqli_query($conn,"select * from tb_user where user_name ='{$user}'and
 user_pwd='{$pwd}'");
$num = mysqli_num_rows($result);
if($num > 0){
   // echo "登入成功";
    setcookie("name",$user,time()+(3600*24*$expire));
    setcookie("pwd",$pwd,time()+(3600*24*$expire));
    session_start();
    $_SESSION['name']=$user;
    //网页重定向
    header("refresh:1;url=index.php");
}
else{
    echo"登入失败";
}
3.2功能演示(界面)
首页:

注册页面:

登录页面:

添加菜品页面:

客户挑选页面

查询菜品页面

删除订单页面

4.总结与收获
经过这一学期的 php课程设计,我尝试着去建立了一个简易的 php网上点菜系统。在系统设计的初期,我觉得很迷茫。因为平时我就没怎么学好这门课程,对这次的程序设计,心里很没底。觉得自己可能完成不了这个了。后来我发现,大家都跟我差不多,但是大家都没有放弃,于是我又鼓起了勇气继续我的设计,并且把时间安排都规划好了。此时,我明白了一个道理,最可怕的不是自己不知道该怎么做,而是自己没有做事情的计划。只要有了计划,并按照计划做事,没有什么办不到的。在设计过程中,同学们相互帮助,让我感受到了合作的力量,也增强了同学之间的感情。相信这次的课程设计,必将给我带来很深的影响。
这次的实训给予了我不同的学习方法和体验,让我深切的认识到实践的重要性。在以后的学习过程中,我会更加注重自己的操作能力和应变能力,多与这个社会进行接触,让自己更早适应这个陌生的环境,相信在不久的将来,可以打造一片属于自己的天地。
附数据库代码:
/*
 Navicat MySQL Data Transfer
 Source Server         : 本机MYSQL
 Source Server Type    : MySQL
 Source Server Version : 50719
 Source Host           : localhost:3306
 Source Schema         : userdb
 Target Server Type    : MySQL
 Target Server Version : 50719
 File Encoding         : 65001
 Date: 15/12/2022 19:53:00
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for menu
-- ----------------------------
DROP TABLE IF EXISTS `menu`;
CREATE TABLE `menu`  (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `price` int(11) NOT NULL,
  `content` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL,
  INDEX `id`(`id`) USING BTREE
) ENGINE = MyISAM AUTO_INCREMENT = 23 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of menu
-- ----------------------------
-- ----------------------------
-- Table structure for order
-- ----------------------------
DROP TABLE IF EXISTS `order`;
CREATE TABLE `order`  (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '编号',
  `name` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '菜品名称',
  `price` varchar(40) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '菜品价格',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 40 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of order
-- ----------------------------
-- ----------------------------
-- Table structure for tb_user
-- ----------------------------
DROP TABLE IF EXISTS `tb_user`;
CREATE TABLE `tb_user`  (
  `user_name` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `user_pwd` int(11) NOT NULL,
  `user_tel` varchar(11) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL
) ENGINE = MyISAM CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of tb_user
-- ----------------------------
INSERT INTO `tb_user` VALUES ('张三', 123, '15484952361');
INSERT INTO `tb_user` VALUES ('李四', 123, '15946231572');
INSERT INTO `tb_user` VALUES ('张三', 123, '12345654321');
INSERT INTO `tb_user` VALUES ('李四', 1234, '12345654321');
SET FOREIGN_KEY_CHECKS = 1;



















