PHP结课报告-简单的点菜系统(完整版,附源码与数据库)

news2024/9/28 19:27:10

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;

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/129177.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

项目经理通过甘特图编制项目计划的方法

项目有个特征叫 渐进明晰 &#xff0c;指一个项目不可能一开始就能想到最后交付成果的全部细节&#xff0c;项目最终的交付成果到底长啥样是随着项目的推进慢慢变得清晰的&#xff0c;而这个变化的过程不仅需要项目经理的经验与能力&#xff0c;还需要借助项目管理工具的帮助。…

一文讲清「敏捷路线图」,从此不再掉入瀑布陷阱

尽管许多组织和团队声称自己非常敏捷&#xff0c;但他们仍在使用瀑布的方式规划产品。为什么会这样&#xff1f;我们该如何改变这种「错误敏捷」&#xff1f; 原则上&#xff0c;践行敏捷开发很简单&#xff1a;构建一个增量&#xff1b;测试这个增量&#xff1b;了解需要改变…

webdriver的尝试:四 【移动端的使用appium-定位与获取代码】

文章目录界面的简单认识和使用参考我们前面使用webdriver可以实现&#xff1a;使用代码&#xff0c;自动化打开浏览器及指定页面&#xff0c;定位元素&#xff0c;获取内容或者模仿操作那么使用移动端&#xff0c;依然需要实现定位与操作 主要就是在appium inspector上进行操作…

开源全球公司贡献 49 名,涛思数据荣登 2022 中国开发者影响力年度榜单

12 月 28 日&#xff0c;CSDN 在北京举行 “2022 中国开发者影响力盛典暨 CSDN 企业生态汇”活动&#xff0c;同时正式发布 2022 中国开发者影响力年度榜单。本次公布的榜单主要包括年度开源贡献企业、年度开源影响力项目、年度开发者社区、年度数字化创新企业、年度优秀雇主企…

蓝桥杯Python练习题13-圆的面积

资源限制   内存限制&#xff1a;256.0MB C/C时间限制&#xff1a;1.0s Java时间限制&#xff1a;3.0s Python时间限制&#xff1a;5.0s 问题描述   给定圆的半径r&#xff0c;求圆的面积。 输入格式   输入包含一个整数r&#xff0c;表示圆的半径。 输出格式   输出…

自然语言处理复习

目录 第 3 章 深度学习基础 第 4 章 语言模型词向量 第 5 章 NLP中的注意力机制 第 6 章 NLP基础任务 第 7 章 预训练语言模型 第 3 章 深度学习基础 1. 人工神经网络 2. 激活函数 &#xff08;1&#xff09;激活函数的作用 为了增强网络的表达能力&#xff0c;需要引入…

在你的岗位中领导:为人力资源职员提供提升招聘管理能力

香港 (Xinwengao.com) — 每年外籍老师表示他们因为沟通问题停止考虑某间学校。这会发生有几个原因但大部分则是因为前线员工并没有感受到得到可以维持与候选人互动。 PD Academia 在此提供这个双语培训课程来帮助中国的学校提升招聘管理能力&#xff1a; 在你的岗位中领导&a…

数字藏品年终盘点:从长坡厚雪到无人问津,潮起潮落的2022

文/尹宁 出品/陀螺研究院 数字藏品&#xff0c;无疑是2022年我国区块链界最为瞩目的应用&#xff0c;在这一年中&#xff0c;数字藏品行业从高歌猛进到急速刹车、从企业扎堆到巨头退场&#xff0c;从需求高涨到被迫出清&#xff0c;经历了跌宕起伏、高潮迭起的发展历程。 上…

ARM64内存虚拟化分析(8)coalesed MMIO处理

从前面MMIO的处理可以看到&#xff0c;每次访问MMIO都会导致虚拟机退了到QEMU中。很多时候多个MMIO操作&#xff0c;这个时候可以先将前面的MMIO操作保存起来&#xff0c;等到最后一个MMIO的时候&#xff0c;再一起退出到QEMU中处理&#xff0c;这就是coalesced MMIO。目前只支…

新概念1 课文和单词(2022/12/28)

前言: 学了多年的英语&#xff0c;在交流或写作中或多或少有用错的地方。估计看这篇博客的你&#xff0c;或许也和我遇到同样的问题。 为此找新概念系列书籍4本&#xff0c;作为系统性查漏补缺的工具。每天更新10课内容&#xff0c;从基础到提升。从简单到深入&#xff0c;循序…

CSS 特殊字符 ‘#‘ 、‘.’ 、‘*’、‘:’、空格“ ”、 ‘>’ , ‘,’

# 号&#xff1a; #号的作用是对应html中的标签的id属性&#xff0c;写法为#name。如#p1{...}会给<p id"p1">ID is p1</p>增加样式。具体事例如下&#xff1a; HTML代码&#xff1a; <div id"p1"> </div><!-- CSS代码&#…

How to use template

1. 模板变量 注意&#xff1a;在manage.py路径下启动shell My name is hjb 我们可以调用Template类中的render方法来对模板进行一个渲染&#xff0c;这时需要用一个Context来传递它&#xff0c;这个Context是一系列变量和他们值得一个集合得字典 首先建立&#xff0c;然后再vie…

IT运维工单高效协同,助力打造一站式运维方案

随着经济全球化的发展趋势&#xff0c;信息系统在企业运营中占据着愈发重要的位置。业务系统越来越多&#xff0c;用户对信息系统的依赖性越来越强&#xff0c;关键业务系统的中断都将导致企业业务、服务的中断&#xff0c;极大的影响了企业业务稳定运行和持续发展。因此企业需…

使用Visual Studio Installer打包Unity的exe应用

前言 Unity在PC端更新软件的方法。 一、下图是Unity发布出来的应用 二、安装Microsoft Visual Studio Installer Projects插件 &#xff08;1&#xff09;打开vs&#xff0c;我这里用的是vs2019 &#xff08;2&#xff09;点击扩展->管理扩展&#xff0c;如果没有安装过&…

注册 openAI 与 ChatGPT 一起对话

文章目录1. 背景2. 注册短信接受平台3. 注册 OpenAI 账号3.1 邮箱注册3.2 手机验证4. 登陆并对话5. 场景预备条件&#xff1a;科学上网 1. 背景 ChatGPT 是有史以来向公众发布的最好的人工智能聊天机器人。它由旧金山人工智能公司 OpenAI 构建&#xff0c;该公司还负责 GPT-3 …

坚鹏:中国邮政储蓄银行银行业同业竞争策略分析培训圆满结束

数字化转型背景下&#xff0c;中国邮政储蓄银行厦门市分行为了更好地落实总行十四五战略&#xff0c;特别举办了2022年管理干部赋能培训班。 银行业的竞争越来越激烈&#xff0c;银行数字化转型成为实现银行高质量发展的重要突破口&#xff0c;中国邮政储蓄银行厦门市分行充分认…

塔望3W消费战略案丨聚焦川崎火锅料,回归赛道一梯队

川崎 火锅料 客户&#xff1a;上海新川崎食品有限公司 品牌&#xff1a;川崎 服务&#xff1a;3W消费战略 品牌全案 项目背景 上世纪90年代&#xff0c;一句“吃火锅&#xff0c;没川崎怎么行”&#xff0c;响彻大江南北&#xff0c;让川崎走进千家万户&#xff0c;成为当时…

体育锻炼与饮食相结合:调节肠道菌群来预防治疗代谢性疾病

谷禾健康 久坐不动的生活方式已逐渐成为现代社会很多人的一种常态&#xff0c;因此导致2型糖尿病 、肥胖、心血管疾病和非酒精性脂肪肝等代谢性疾病的发病率上升。 ★ 代谢性疾病严重危害人体健康 根据世界卫生组织数据库&#xff0c;2019年&#xff0c;代谢风险&#xff08;即…

ubantu 配置及解决问题

1、安装GCC出现等待缓存锁 需要将其冲突的删除&#xff0c;利用下面三个代码后重新输入下载即可。 sudo rm /var/lib/dpkg/lock-frontend sudo rm /var/cache/apt/archives/lock sudo rm /var/lib/dpkg/lock2、开启共享文件夹&#xff1a; 参考以下链接&#xff0c;在进行的…

【KubeEdge】V-1.12.1 使用helm安装,并启用kubectl log/exec高级特性

内容提要&#xff1a; 云端使用helm安装cloudcore边缘端使用keadm join纳管到云端修改边缘端配置使其支持IptableManger把服务部署到边缘端&#xff0c;并体验kubeclt logs/exec ------------------------------------------------------------------------------------------…