主頁 > 後端開發 > 電子商城專案開發(后臺功能模塊開發)

電子商城專案開發(后臺功能模塊開發)

2020-09-20 06:44:53 後端開發

后臺登陸頁login.php

    <?php
    //1.連接資料庫 (創建一個資料庫,創建資料表 test_admin)
    //id, adminuser, adminpass, created_at, login_at, login_ip
    require '../db.func.php';
    require '../tools.func.php';
    // POST提交
    if (!empty($_POST['adminuser'])) {
      //2.查詢用戶名和密碼是否正確 adminuser adminpass
        $prefix = getDBPrefix();
        $adminuser = htmlentities($_POST['adminuser']);
        $adminpass = md5(htmlentities($_POST['adminpass']));
        $sql = "SELECT id, adminuser FROM {$prefix}admin 
                        WHERE adminuser = '$adminuser' 
                        AND adminpass = '$adminpass'";

        $res = queryOne($sql);
        if ($res) {
        //3.寫入session
            setSession('admin',
                ['adminuser' => $adminuser, 'id' => $res['id']]
            );
            $login_at = date('Y-m-d H:i:s');
            $ip = $_SERVER['REMOTE_ADDR'] == '::1' ? '127.0.0.1' : $_SERVER['REMOTE_ADDR'];
            $login_ip = ip2long($ip);
            $sql = "UPDATE {$prefix}admin 
                            SET login_at = '$login_at', login_ip = '$login_ip' 
                            WHERE id = '{$res['id']}'";
            execute($sql);
        //4.跳轉到index.php
            header('location: index.php');
        } else {
            setInfo('用戶名或者密碼錯誤');
        }
    }

    ?>
    <!doctype html>
    <html>

    <head>
      <title>商城</title>
      <!-- Required meta tags -->
      <meta charset="utf-8">
      <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
      <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
      <!--     Fonts and icons     -->
      <link rel="stylesheet" type="text/css" href="assets/css/googlefonts.css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons" />
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
      <!-- Material Kit CSS -->
      <link href="assets/css/material-dashboard.css?v=2.1.1" rel="stylesheet" />
    </head>

    <body>
      <div class="wrapper ">
        <div>
          <div>
            <div class="container" style="width: 50%;margin-top: 250px;">
              <div class="row">
                <div class="col-md-12">
                  <div class="col-md-12">
                    <div class="card">

                      <div class="card-header card-header-primary">
                        <h4 class="card-title">登錄</h4>
                        <p class="card-category">以管理員身份登錄后臺</p>
                      </div>
                      <div class="card-body">
                          <p><?php if (hasInfo()) echo getInfo(); ?></p>
                        <form action="login.php" method="post">
                          <div class="row">
                            <div class="col-md-12">
                              <div class="form-group">
                                <label class="bmd-label-floating">用戶名</label>
                                <input type="text" name="adminuser" class="form-control">
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-12">
                              <div class="form-group">
                                <label class="bmd-label-floating">密碼</label>
                                <input type="password" name="adminpass" class="form-control">
                              </div>
                            </div>
                          </div>
                          <button type="submit" class="btn btn-primary pull-right">登錄</button>
                          <div class="clearfix"></div>
                        </form>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <script src="assets/js/core/jquery.min.js"></script>
      <script src="assets/js/core/popper.min.js"></script>
      <script src="assets/js/core/bootstrap-material-design.min.js"></script>
    </body>

    </html>

資料庫結構shop.sql

    /*
     Navicat Premium Data Transfer

     Source Server         : 127.0.0.1
     Source Server Type    : MySQL
     Source Server Version : 80012
     Source Host           : localhost:3306
     Source Schema         : shop

     Target Server Type    : MySQL
     Target Server Version : 80012
     File Encoding         : 65001

     Date: 26/01/2019 10:13:57
    */

    SET NAMES utf8mb4;
    SET FOREIGN_KEY_CHECKS = 0;

    -- ----------------------------
    -- Table structure for test_admin
    -- ----------------------------
    DROP TABLE IF EXISTS `test_admin`;
    CREATE TABLE `test_admin` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `adminuser` varchar(50) NOT NULL DEFAULT '',
      `adminpass` char(32) NOT NULL DEFAULT '',
      `created_at` varchar(255) NOT NULL DEFAULT '',
      `login_at` varchar(255) NOT NULL DEFAULT '' ,
      `login_ip` bigint(20) NOT NULL DEFAULT '0',
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

    -- ----------------------------
    -- Records of test_admin
    -- ----------------------------
    BEGIN;
    INSERT INTO `test_admin` VALUES (1, 'admin', '0192023a7bbd73250516f069df18b500', '2019-01-23 20:21:03', '2019-01-24 12:56:48', 2130706433);
    COMMIT;

    -- ----------------------------
    -- Table structure for test_cart
    -- ----------------------------
    DROP TABLE IF EXISTS `test_cart`;
    CREATE TABLE `test_cart` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
      `quantity` int(10) unsigned NOT NULL DEFAULT '0',
      `products` text,
      `uid` int(10) unsigned NOT NULL DEFAULT '0',
      `created_at` varchar(255) NOT NULL DEFAULT '' ,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;

    -- ----------------------------
    -- Records of test_cart
    -- ----------------------------
    BEGIN;
    INSERT INTO `test_cart` VALUES (2, 21700.00, 3, '{\"3\":{\"quantity\":2,\"product\":{\"id\":\"3\",\"name\":\"Macbook Pro\",\"price\":\"8800.00\",\"code\":\"88888888\",\"description\":\"Macbook Pro\"}},\"4\":{\"quantity\":1,\"product\":{\"id\":\"4\",\"name\":\"\\u534e\\u4e3a\\u624b\\u673a\",\"price\":\"4100.00\",\"code\":\"929868123123123\",\"description\":\"\\u5546\\u54c1\\u63cf\\u8ff0\\uff1a\\r\\n\\r\\n\\u8fd9\\u662f\\u534e\\u4e3a\\u624b\\u673a\"}}}', 5, '2019-01-24 10:53:24');
    COMMIT;

    -- ----------------------------
    -- Table structure for test_order
    -- ----------------------------
    DROP TABLE IF EXISTS `test_order`;
    CREATE TABLE `test_order` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
      `quantity` int(10) unsigned NOT NULL DEFAULT '0',
      `products` text,
      `uid` int(10) unsigned NOT NULL DEFAULT '0',
      `created_at` varchar(255) NOT NULL DEFAULT '' ,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

    -- ----------------------------
    -- Records of test_order
    -- ----------------------------
    BEGIN;
    INSERT INTO `test_order` VALUES (1, 17600.00, 2, '{\"3\":{\"quantity\":2,\"product\":{\"id\":\"3\",\"name\":\"Macbook Pro\",\"price\":\"8800.00\",\"code\":\"88888888\",\"description\":\"Macbook Pro\"}}}', 5, '2019-01-24 12:46:33');
    COMMIT;

    -- ----------------------------
    -- Table structure for test_product
    -- ----------------------------
    DROP TABLE IF EXISTS `test_product`;
    CREATE TABLE `test_product` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `name` varchar(200) NOT NULL DEFAULT '',
      `code` varchar(100) NOT NULL DEFAULT '',
      `description` text,
      `stock` int(10) unsigned NOT NULL DEFAULT '0',
      `price` decimal(10,2) unsigned NOT NULL DEFAULT '0.00',
     `created_at` varchar(255) NOT NULL DEFAULT '' ,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

    -- ----------------------------
    -- Records of test_product
    -- ----------------------------
    BEGIN;
    INSERT INTO `test_product` VALUES (3, 'Macbook Pro', '88888888', 'Macbook Pro', 99, 8800.00, '2019-01-24 00:19:28');
    INSERT INTO `test_product` VALUES (4, '華為手機', '929868123123123', '商品描述:\r\n\r\n這是華為手機', 99, 4100.00, '2019-01-24 00:31:28');
    COMMIT;

    -- ----------------------------
    -- Table structure for test_user
    -- ----------------------------
    DROP TABLE IF EXISTS `test_user`;
    CREATE TABLE `test_user` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `username` varchar(100) NOT NULL DEFAULT '',
      `password` char(32) NOT NULL DEFAULT '',
      `name` varchar(100) NOT NULL DEFAULT '',
      `age` tinyint(3) unsigned NOT NULL DEFAULT '0',
      `email` varchar(100) NOT NULL DEFAULT '',
      `phone` varchar(20) NOT NULL DEFAULT '',
     `created_at` varchar(255) NOT NULL DEFAULT '' ,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8;

    -- ----------------------------
    -- Records of test_user
    -- ----------------------------
    BEGIN;
    INSERT INTO `test_user` VALUES (3, 'zhangsan', '4297f44b13955235245b2497399d7a93', '張三', 28, '[email protected]', '13200000000', '2019-01-23 23:54:34');
    INSERT INTO `test_user` VALUES (4, 'wangwu', '4297f44b13955235245b2497399d7a93', '', 0, '[email protected]', '', '2019-01-24 09:21:45');
    INSERT INTO `test_user` VALUES (5, 'zhaoliu', '4297f44b13955235245b2497399d7a93', '', 0, '[email protected]', '', '2019-01-24 09:35:05');
    COMMIT;

    SET FOREIGN_KEY_CHECKS = 1;

配置資料庫檔案config.php

    <?php
    /**
     * Created by PhpStorm.
     * Date: 2019/1/23
     * Time: 20:22
     */
    date_default_timezone_set('PRC');
    return [
        'DB_HOST' => '127.0.0.1',
        'DB_PORT' => '3306',
        'DB_USER' => 'root',
        'DB_PASS' => '123456',
        'DB_NAME' => 'test_shop',
        'DB_PREFIX' => 'test_',
        'DB_CHARSET' => 'utf8',
    ];

操作資料庫函式db.func.php

    <?php

    function connect()
    {
        $config = require dirname(__FILE__) . '/config.php';
        $mysqli = @mysqli_connect(
            $config['DB_HOST'] . ':' . $config['DB_PORT'],
            $config['DB_USER'],
            $config['DB_PASS'],
            $config['DB_NAME']
        ) or die('Connect Error: ' . mysqli_connect_errno() . '-' . mysqli_connect_error());
        mysqli_set_charset($mysqli, $config['DB_CHARSET']);
        return $mysqli;
    }

    function queryOne($sql)
    {
        $mysqli = connect();
        $result = mysqli_query($mysqli, $sql);
        $data = [];
        if ($result && mysqli_num_rows($result) > 0) {
            $data = mysqli_fetch_assoc($result);
        }
        return $data;
    }

    function query($sql)
    {
        $mysqli = connect();
        $result = mysqli_query($mysqli, $sql);
        $data = [];
        if ($result && mysqli_num_rows($result) > 0) {
            while ($res = mysqli_fetch_assoc($result)) {
                $data[] = $res;
            }
        }
        return $data;
    }

    function getDBPrefix()
    {
        $config = require dirname(__FILE__) . '/config.php';
        return $config['DB_PREFIX'];
    }

    function execute($sql)
    {
        $mysqli = connect();
        mysqli_query($mysqli, $sql);
        return mysqli_affected_rows($mysqli) > 0;
    }

公共函式檔案tools.func.php

    <?php
    /**
     * Created by PhpStorm.
     * Date: 2019/1/23
     * Time: 20:31
     */

    function setSession($key, $data, $prefix = '')
    {
        session_id() || @session_start();
        if (!empty($prefix)) {
            $_SESSION[$prefix][$key] = $data;
        } else {
            $_SESSION[$key] = $data;
        }
    }

    function getSession($key, $prefix = '')
    {
        session_id() || @session_start();
        if (!empty($prefix)) {
            return isset($_SESSION[$prefix][$key]) ? $_SESSION[$prefix][$key] : [];
        } else {
            return isset($_SESSION[$key]) ? $_SESSION[$key] : [];
        }
    }

    function deleteSession($key, $prefix = '')
    {
        session_id() || @session_start();
        if (!empty($prefix)) {
            $_SESSION[$prefix][$key] = null;
        } else {
            $_SESSION[$key] = null;
        }
    }

    function setInfo($info)
    {
        setSession('info', $info, 'system');
    }

    function getInfo()
    {
       $info = getSession('info', 'system');
       deleteSession('info', 'system');
       return $info;
    }

    function hasInfo()
    {
       return !empty(getSession('info', 'system'));
    }

判斷是否有登陸權限auth.php

    <?php
    /**
     * Created by PhpStorm.
     * Date: 2019/1/23
     * Time: 22:07
     */

    if (empty(getSession('adminuser', 'admin'))) {
        header('location: login.php');
        exit;
    }

登陸成功后進入后臺首頁index.php

    <?php
    require '../db.func.php';
    require '../tools.func.php';
    require 'auth.php';
    //1.查詢資料庫 test_admin
    //2.寫sql陳述句
    $prefix = getDBPrefix();
    $sql = "SELECT id,adminuser,created_at,login_at,login_ip 
                    FROM {$prefix}admin ORDER BY created_at DESC";
    $data = https://www.cnblogs.com/chenyingying0/p/query($sql);
    //3.遍歷資料

    require'header.php';
    ?>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header card-header-primary">
                    <h4 class="card-title ">所有管理員</h4>
                    <p class="card-category"> 控制臺所有管理員串列</p>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead class=" text-primary">
                            <th>
                                ID
                            </th>
                            <th>
                                用戶名
                            </th>
                            <th>
                                創建時間
                            </th>
                            <th>
                                最后登錄時間
                            </th>
                            <th>
                                最后登錄IP
                            </th>
                            </thead>
                            <tbody>
                            <?php foreach ($data as $admin): ?>
                            <tr>
                                <td>
                                    <?php echo $admin['id']; ?>
                                </td>
                                <td>
                    <?php echo $admin['adminuser']; ?>
                                </td>
                                <td>
                    <?php echo $admin['created_at']; ?>
                                </td>
                                <td>
                    <?php echo $admin['login_at']; ?>
                                </td>
                                <td>
                    <?php echo long2ip($admin['login_ip']); ?>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php
    require 'footer.php';
    ?>

header.php

    <?php
    $script = basename($_SERVER['SCRIPT_FILENAME']);
    // 控制臺 index.php admin_edit.php
    // 用戶管理 users.php user_add.php user_edit.php
    // 商品管理 products.php product_add.php product_edit.php
    ?>
    <!doctype html>
    <html>

    <head>
        <title>商城</title>
        <!-- Required meta tags -->
        <meta charset="utf-8">
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <!--     Fonts and icons     -->
        <link rel="stylesheet" type="text/css"
              href="assets/css/googlefonts.css?family=Roboto:300,400,500,700|Roboto+Slab:400,700|Material+Icons"/>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css">
        <!-- Material Kit CSS -->
        <link href="assets/css/material-dashboard.css?v=2.1.1" rel="stylesheet"/>
    </head>

    <body>
    <div class="wrapper ">
        <div class="sidebar" data-color="purple" data-background-color="white">
            <div class="logo">
                <a href="index.php" class="simple-text logo-normal">
                    商城
                </a>
            </div>
            <div class="sidebar-wrapper">
                <ul class="nav">
                    <li class="nav-item <?php echo substr($script, 0, 5) == 'index' || substr($script, 0, 5) == 'admin' ? 'active' : ''; ?>">
                        <a class="nav-link" href="index.php">
                            <i class="material-icons">dashboard</i>
                            <p>控制臺</p>
                        </a>
                    </li>
                    <li class="nav-item <?php echo substr($script, 0, 4) == 'user' ? 'active' : ''; ?>">
                        <a class="nav-link" href="users.php">
                            <i class="material-icons">person</i>
                            <p>用戶管理</p>
                        </a>
                    </li>
                    <li class="nav-item <?php echo substr($script, 0, 7) == 'product' ? 'active' : ''; ?>">
                        <a class="nav-link" href="products.php">
                            <i class="material-icons">library_books</i>
                            <p>商品管理</p>
                        </a>
                    </li>
                    <li class="nav-item <?php echo substr($script, 0, 4) == 'cart' ? 'active' : ''; ?>">
                        <a class="nav-link" href="carts.php">
                            <i class="material-icons">shopping_cart</i>
                            <p>購物車管理</p>
                        </a>
                    </li>
                    <li class="nav-item <?php echo substr($script, 0, 5) == 'order' ? 'active' : ''; ?>">
                        <a class="nav-link" href="orders.php">
                            <i class="material-icons">list</i>
                            <p>訂單管理</p>
                        </a>
                    </li>
                    <!-- your sidebar here -->
                </ul>
            </div>
        </div>
        <div class="main-panel">
            <!-- Navbar -->
            <nav class="navbar navbar-expand-lg navbar-transparent navbar-absolute fixed-top ">
                <div class="container-fluid">
                    <div class="navbar-wrapper">
                        <a class="navbar-brand" href="index.php">控制臺</a>
                    </div>
                    <div class="collapse navbar-collapse justify-content-end">
                        <ul class="navbar-nav">
                            <li class="nav-item dropdown">
                                <a class="nav-link" href="#" id="navbarDropdownProfile" data-toggle="dropdown" aria-haspopup="true"
                                   aria-expanded="false">
                                    <i class="material-icons">person</i>
                                    <p class="d-lg-none d-md-block">
                                        管理員
                                    </p>
                                </a>
                                <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownProfile">
                                    <a class="dropdown-item" href="admin_edit.php">編輯</a>
                                    <div class="dropdown-divider"></div>
                                    <a class="dropdown-item" href="logout.php">退出</a>
                                </div>
                            </li>
                            <!-- your navbar here -->
                        </ul>
                    </div>
                </div>
            </nav>
            <!-- End Navbar -->
            <div class="content">
                <div class="container-fluid">

footer.php

    </div>
    </div>
    </div>
    </div>
    <script src="assets/js/core/jquery.min.js"></script>
    <script src="assets/js/core/popper.min.js"></script>
    <script src="assets/js/core/bootstrap-material-design.min.js"></script>
    </body>

    </html>

管理員賬號密碼修改admin_edit.php

    <?php
    require '../tools.func.php';
    require 'auth.php';
    require '../db.func.php';
    $current_user = getSession('admin');

    //1.判斷是否為post提交
    if (!empty($_POST['adminpass'])) {
      //2.驗證新密碼和確認密碼是否一致
        $adminpass = md5(htmlentities($_POST['adminpass']));
        $newpass = htmlentities($_POST['newpass']);
        $confirmpass = htmlentities($_POST['confirmpass']);
        if ($newpass != $confirmpass) {
            setInfo('兩次密碼輸入不一致');
        } else {
        //3.驗證舊密碼是否正確 (查詢資料庫 用id,adminpass)
        $prefix = getDBPrefix();
        $sql = "SELECT id FROM {$prefix}admin 
                    WHERE id = '{$current_user['id']}' 
                    AND adminpass = '$adminpass'
                    ";
        $res = queryOne($sql);
        //4.更新資料表 imooc_admin adminpass
        if ($res) {
          $pass = md5($newpass);
          $sql = "UPDATE {$prefix}admin 
                    SET adminpass = '$pass'
                    WHERE id = '{$current_user['id']}'";
          if (execute($sql)) {
              setInfo('修改密碼成功');
          } else {
              setInfo('修改密碼失敗');
          }
        } else {
            setInfo('舊密碼不正確!');
        }
        }

        //5.顯示結果到頁面
    }



    require 'header.php';
    ?>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header card-header-primary">
                    <h4 class="card-title">修改密碼</h4>
                    <p class="card-category">修改當前管理員密碼</p>
                </div>
                <div class="card-body">
                    <?php if (hasInfo()) echo getInfo(); ?>
                    <form action="admin_edit.php" method="post">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="bmd-label-floating">用戶名</label>
                                    <input type="text" disabled name="adminuser" value="<?php echo $current_user['adminuser']; ?>" class="form-control">
                                </div>
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="bmd-label-floating">舊密碼</label>
                                    <input type="password" name="adminpass" class="form-control">
                                </div>
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="bmd-label-floating">新密碼</label>
                                    <input type="password" name="newpass" class="form-control">
                                </div>
                            </div>

                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="bmd-label-floating">確認密碼</label>
                                    <input type="password" name="confirmpass" class="form-control">
                                </div>
                            </div>
                        </div>

                        <button type="submit" class="btn btn-primary pull-right">修改</button>
                        <div class="clearfix"></div>
                    </form>
                </div>
            </div>
        </div>

    </div>
    <?php
    require 'footer.php';
    ?>

管理員后臺登出logout.php

    <?php
    /**
     * Created by PhpStorm.
     * Date: 2019/1/23
     * Time: 22:06
     */

    // 1. 洗掉當前登錄用戶的session
    require '../tools.func.php';

    deleteSession('admin');

    header('location: login.php');

用戶串列顯示users.php

    <?php
    require '../db.func.php';
    require '../tools.func.php';
    require 'auth.php';
    // 1. 寫sql查詢
    $prefix = getDBPrefix();
    $sql = "SELECT id, username, age, name, email, phone, created_at
                    FROM {$prefix}user ORDER BY created_at DESC";
    // 2. 執行查詢
    $res = query($sql);
    // 3. 遍歷結果

    require 'header.php';
    ?>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header card-header-primary">
                    <div class="row">
                        <div class="col-10">
                            <h4 class="card-title ">所有用戶</h4>
                            <p class="card-category"> 用戶串列</p>
                        </div>
                        <div class="col-2">
                            <a href="user_add.php" class="btn btn-round btn-info" style="margin-left: 20px;">添加用戶</a>
                        </div>
                    </div>
                </div>
                <div class="card-body">
                    <p><?php if (hasInfo()) echo getInfo(); ?></p>
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead class=" text-primary">
                            <th>
                                ID
                            </th>
                            <th>
                                用戶名
                            </th>
                            <th>
                                姓名
                            </th>
                            <th>
                                年齡
                            </th>
                            <th>
                                郵箱
                            </th>
                            <th>
                                聯系電話
                            </th>
                            <th>
                                注冊時間
                            </th>
                            <th>
                                操作
                            </th>
                            </thead>
                            <tbody>
                            <?php foreach ($res as $user): ?>
                            <tr>
                                <td>
                                    <?php echo $user['id']; ?>
                                </td>
                                <td>
                    <?php echo $user['username']; ?>
                                </td>
                                <td>
                    <?php echo $user['name']; ?>
                                </td>
                                <td>
                    <?php echo $user['age']; ?>
                                </td>
                                <td>
                    <?php echo $user['email']; ?>
                                </td>
                                <td>
                    <?php echo $user['phone']; ?>
                                </td>
                                <td>
                    <?php echo $user['created_at']; ?>
                                </td>
                                <td>
                                    <a href="user_edit.php?id=<?php echo $user['id']; ?>">編輯</a>
                                    |
                                    <a href="user_del.php?id=<?php echo $user['id']; ?>">洗掉</a>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php
    require 'footer.php';
    ?>

添加用戶user_add.php

    <?php
    require '../tools.func.php';
    require '../db.func.php';
    require 'auth.php';
    if (!empty($_POST['username'])) {
        // 1. 接收post資料
        $username = htmlentities($_POST['username']);
        $password = htmlentities($_POST['password']);
        $confirmpass = htmlentities($_POST['confirmpass']);
        $name = htmlentities($_POST['name']);
        $age = htmlentities($_POST['age']);
        $email = htmlentities($_POST['email']);
        $phone = htmlentities($_POST['phone']);
        $created_at = date('Y-m-d H:i:s');
        $prefix = getDBPrefix();
        // 2. 驗證密碼輸入是否一致
        if ($password != $confirmpass) {
            setInfo('兩次密碼輸入不一致');
        } else {
            $password = md5($password);
        // 3. 寫sql陳述句
            $sql = "INSERT INTO {$prefix}user(username, password, age, name, email, phone, created_at)
                            VALUES('$username', '$password', '$age', '$name', '$email', '$phone', '$created_at')";
        // 4. 執行添加,如果成功,顯示成功資訊
            if (execute($sql)) {
                setInfo('添加成功');
            } else {
          setInfo('添加失敗');
            }
        }

    }


    require 'header.php';
    ?>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header card-header-primary">
                    <h4 class="card-title">添加用戶</h4>
                    <p class="card-category">添加一個用戶</p>
                </div>
                <div class="card-body">
                    <?php if (hasInfo()) echo getInfo(); ?>
                    <form action="user_add.php" method="post">
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="bmd-label-floating">用戶名</label>
                                    <input type="text" name="username" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="bmd-label-floating">密碼</label>
                                    <input type="password" name="password" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="bmd-label-floating">確認密碼</label>
                                    <input type="password" name="confirmpass" class="form-control">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="bmd-label-floating">姓名</label>
                                    <input type="text" name="name" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="bmd-label-floating">年齡</label>
                                    <input type="number" name="age" class="form-control">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="bmd-label-floating">聯系電話</label>
                                    <input type="text" name="phone" class="form-control">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="bmd-label-floating">電子郵箱</label>
                                    <input type="email" name="email" class="form-control">
                                </div>
                            </div>
                        </div>
                        <button type="submit" class="btn btn-primary pull-right">添加用戶</button>
                        <div class="clearfix"></div>
                    </form>
                </div>
            </div>
        </div>

    </div>
    <?php
    require 'footer.php';
    ?>

修改用戶資訊user_edit.php

    <?php
    require '../db.func.php';
    require '../tools.func.php';
    require 'auth.php';
    // 1. 接收id
    $id = intval($_GET['id']);
    if (empty($id)) {
        header('location: users.php');
    }
    // 2. 根據id查詢用戶
    $prefix = getDBPrefix();
    $sql = "SELECT id,username,age,email,phone,name 
                    FROM {$prefix}user WHERE id = '$id'";
    $current_user = queryOne($sql);
    if (empty($current_user)) {
      header('location: users.php');
    }
    // 3. 將查詢出的用戶的資料放入到表單當中
    // 4. 判斷是否為post提交
    if (!empty($_POST['name'])) {
      // 5. 接收post資料
        $name = htmlentities($_POST['name']);
        $age = htmlentities($_POST['age']);
        $email = htmlentities($_POST['email']);
        $phone = htmlentities($_POST['phone']);
        // 6. 更新資料記錄
        $sql = "UPDATE {$prefix}user 
                        SET name = '$name', age = '$age', email = '$email', phone = '$phone'
                        WHERE id = '$id'";
        if (execute($sql)) {
        $current_user = array_merge($current_user, $_POST);
            setInfo('更新成功');
        } else {
            setInfo('更新失敗');
        }
        // 7. 顯示結果
    }


    require 'header.php';
    ?>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header card-header-primary">
                    <h4 class="card-title">修改用戶</h4>
                    <p class="card-category">修改一個用戶</p>
                </div>
                <div class="card-body">
                    <?php if (hasInfo()) echo getInfo(); ?>
                    <form action="user_edit.php?id=<?php echo $id; ?>" method="post">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="bmd-label-floating">用戶名</label>
                                    <input type="text" name="username" value="<?php echo $current_user['username']; ?>" disabled class="form-control">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="bmd-label-floating">姓名</label>
                                    <input type="text" name="name" value="<?php echo $current_user['name']; ?>" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="bmd-label-floating">年齡</label>
                                    <input type="number" name="age" value="<?php echo $current_user['age']; ?>" class="form-control">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="bmd-label-floating">聯系電話</label>
                                    <input type="text" name="phone" value="<?php echo $current_user['phone']; ?>" class="form-control">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="bmd-label-floating">電子郵箱</label>
                                    <input type="email" name="email" value="<?php echo $current_user['email']; ?>" class="form-control">
                                </div>
                            </div>
                        </div>
                        <button type="submit" class="btn btn-primary pull-right">更新資訊</button>
                        <div class="clearfix"></div>
                    </form>
                </div>
            </div>
        </div>

    </div>
    <?php
    require 'footer.php';
    ?>

洗掉用戶user_del.php

    <?php
    /**
     * Created by PhpStorm.
     * Date: 2019/1/24
     * Time: 10:49
     */
    require '../db.func.php';
    require '../tools.func.php';
    require 'auth.php';

    // 1. 接收id
    $id = intval($_GET['id']);
    // 2. 從資料庫當中洗掉對應的資料
    $prefix = getDBPrefix();
    $sql = "DELETE FROM {$prefix}user WHERE id = '$id'";
    if (execute($sql)) {
        setInfo('洗掉成功');
    } else {
        setInfo('洗掉失敗');
    }
    // 3. 跳回到串列頁
    header('location: users.php');

商品串列products.php

    <?php
    require '../tools.func.php';
    require 'auth.php';
    require '../db.func.php';
    $prefix = getDBPrefix();
    $sql = "SELECT * FROM {$prefix}product ORDER BY created_at DESC ";
    $data = https://www.cnblogs.com/chenyingying0/p/query($sql);
    require'header.php';
    ?>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header card-header-primary">
                    <div class="row">
                        <div class="col-10">
                            <h4 class="card-title ">所有商品</h4>
                            <p class="card-category"> 所有商品串列</p>
                        </div>
                        <div class="col-2">
                            <a href="product_add.php" class="btn btn-round btn-info" style="margin-left: 20px;">添加商品</a>
                        </div>
                    </div>

                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-hover" style="table-layout:fixed; ">
                            <thead class=" text-primary">
                            <th width="5%">
                                ID
                            </th>
                            <th>
                                商品編號
                            </th>
                            <th>
                                商品名稱
                            </th>
                            <th>
                                商品描述
                            </th>
                            <th>
                                商品庫存
                            </th>
                            <th>
                                商品單價
                            </th>
                            <th>
                                商品上架時間
                            </th>
                            <th>
                                編輯
                            </th>
                            </thead>
                            <tbody>
                <?php foreach ($data as $pro): ?>
                                <tr>
                                    <td>
                        <?php echo $pro['id']; ?>
                                    </td>
                                    <td>
                        <?php echo $pro['code']; ?>
                                    </td>
                                    <td>
                        <?php echo $pro['name']; ?>
                                    </td>
                                    <td>
                        <?php echo mb_substr($pro['description'], 0, 8, 'utf-8') . '...'; ?>
                                    </td>
                                    <td>
                        <?php echo $pro['stock']; ?>
                                    </td>
                                    <td>
                        <?php echo $pro['price']; ?>
                                    </td>
                                    <td>
                        <?php echo $pro['created_at']; ?>
                                    </td>
                                    <td>
                                        <a href="#">編輯</a>
                                        |
                                        <a href="#">洗掉</a>
                                    </td>
                                </tr>
                <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php
    require 'footer.php';
    ?>

添加商品product_add.php

    <?php
    require '../tools.func.php';
    require 'auth.php';
    require '../db.func.php';
    // 1. 判斷是否為post提交
    if (!empty($_POST['name'])) {
      // 2. 接收post資料
        $name = htmlentities($_POST['name']);
        $code = htmlentities($_POST['code']);
        $price = doubleval($_POST['price']);
        $stock = intval($_POST['stock']);
        $description = htmlentities($_POST['description']);
        $created_at = date('Y-m-d H:i:s');
        // 3. 寫sql陳述句
        $prefix = getDBPrefix();
        $sql = "INSERT INTO {$prefix}product(name, code, price, stock, description, created_at)
                        VALUES('$name', '$code', '$price', '$stock', '$description', '$created_at')";
        // 4. 執行插入
        if (execute($sql)) {
            setInfo('添加成功');
        } else {
        setInfo('添加失敗');
        }
        // 5. 顯示結果
    }


    require 'header.php';
    ?>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header card-header-primary">
                    <h4 class="card-title">添加商品</h4>
                    <p class="card-category">添加一個商品</p>
                </div>
                <div class="card-body">
                    <?php if (hasInfo()) echo getInfo(); ?>
                    <form action="product_add.php" method="post">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="bmd-label-floating">商品名稱</label>
                                    <input type="text" name="name" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="bmd-label-floating">商品單價</label>
                                    <input type="number" name="price" class="form-control">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="bmd-label-floating">商品庫存</label>
                                    <input type="number" name="stock" class="form-control">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="bmd-label-floating">商品編號</label>
                                    <input type="text" name="code" class="form-control">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label>商品描述</label>
                                    <div class="form-group bmd-form-group">
                                        <textarea name="description" class="form-control" rows="5"></textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <button type="submit" class="btn btn-primary pull-right">添加商品</button>
                        <div class="clearfix"></div>
                    </form>
                </div>
            </div>
        </div>

    </div>
    <?php
    require 'footer.php';
    ?>

購物車串列頁carts.php

    <?php
    require '../tools.func.php';
    require '../db.func.php';
    require 'auth.php';
    $prefix = getDBPrefix();
    $sql = "SELECT id, price, quantity, uid, created_at FROM {$prefix}cart ORDER BY created_at DESC";
    $back_cart_data = https://www.cnblogs.com/chenyingying0/p/[];
    $cart = query($sql);
    foreach ($cart as $c) {
      $sql ="SELECT username FROM {$prefix}user WHERE id = '{$c['uid']}'";
      $user = queryOne($sql);
      $c['username'] = $user['username'];
      $back_cart_data[] = $c;
    }
    require 'header.php';
    ?>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header card-header-primary">
                    <div class="row">
                        <div class="col-12">
                            <h4 class="card-title ">所有購物車</h4>
                            <p class="card-category"> 所有購物車串列</p>
                        </div>
                    </div>

                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead class=" text-primary">
                            <th>
                                ID
                            </th>
                            <th>
                                購物車用戶
                            </th>
                            <th>
                                商品總量
                            </th>
                            <th>
                                購物車總價
                            </th>
                            <th>
                                添加時間
                            </th>
                            <th>
                                編輯
                            </th>
                            </thead>
                            <tbody>
                            <?php foreach ($back_cart_data as $cart): ?>
                            <tr>
                                <td>
                                    <?php echo $cart['id']; ?>
                                </td>
                                <td>
                    <?php echo $cart['username']; ?>
                                </td>
                                <td>
                    <?php echo $cart['quantity']; ?>
                                </td>
                                <td>
                    <?php echo $cart['price']; ?>
                                </td>
                                <td>
                    <?php echo $cart['created_at']; ?>
                                </td>
                                <td>
                                    <a href="">洗掉</a>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php
    require 'footer.php';
    ?>

訂單串列orders.php

    <?php
    require '../tools.func.php';
    require 'auth.php';
    require '../db.func.php';
    $prefix = getDBPrefix();
    $sql = "SELECT id, uid, price, quantity, created_at 
                    FROM {$prefix}order ORDER BY created_at DESC";
    $orders = query($sql);
    require 'header.php';
    ?>
    <div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-header card-header-primary">
                    <div class="row">
                        <div class="col-12">
                            <h4 class="card-title ">所有訂單</h4>
                            <p class="card-category"> 所有訂單串列</p>
                        </div>
                    </div>

                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead class=" text-primary">
                            <th>
                                ID
                            </th>
                            <th>
                                下單用戶
                            </th>
                            <th>
                                訂單價格
                            </th>
                            <th>
                                訂單商品數量
                            </th>
                            <th>
                                下單時間
                            </th>
                            </thead>
                            <tbody>
                            <?php foreach($orders as $order): ?>
                            <tr>
                                <td>
                                    <?php echo $order['id']; ?>
                                </td>
                                <td>
                    <?php echo $order['uid']; ?>
                                </td>
                                <td>
                    <?php echo $order['price']; ?>
                                </td>
                                <td>
                      <?php echo $order['quantity']; ?>
                                </td>
                                <td>
                    <?php echo $order['created_at']; ?>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php
    require 'footer.php';
    ?>

轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/86748.html

標籤:PHP

上一篇:利用會話控制實作頁面登錄與注銷功能(高顏值許愿墻實體原始碼)

下一篇:電子商城專案開發(前臺功能模塊開發)

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 【C++】Microsoft C++、C 和匯編程式檔案

    ......

    uj5u.com 2020-09-10 00:57:23 more
  • 例外宣告

    相比于斷言適用于排除邏輯上不可能存在的狀態,例外通常是用于邏輯上可能發生的錯誤。 例外宣告 Item 1:當函式不可能拋出例外或不能接受拋出例外時,使用noexcept 理由 如果不打算拋出例外的話,程式就會認為無法處理這種錯誤,并且應當盡早終止,如此可以有效地阻止例外的傳播與擴散。 示例 //不可 ......

    uj5u.com 2020-09-10 00:57:27 more
  • Codeforces 1400E Clear the Multiset(貪心 + 分治)

    鏈接:https://codeforces.com/problemset/problem/1400/E 來源:Codeforces 思路:給你一個陣列,現在你可以進行兩種操作,操作1:將一段沒有 0 的區間進行減一的操作,操作2:將 i 位置上的元素歸零。最終問:將這個陣列的全部元素歸零后操作的最少 ......

    uj5u.com 2020-09-10 00:57:30 more
  • UVA11610 【Reverse Prime】

    本人看到此題沒有翻譯,就附帶了一個自己的翻譯版本 思考 這一題,它的第一個要求是找出所有 $7$ 位反向質數及其質因數的個數。 我們應該需要質數篩篩選1~$10^{7}$的所有數,這里就不慢慢介紹了。但是,重讀題,我們突然發現反向質數都是 $7$ 位,而將它反過來后的數字卻是 $6$ 位數,這就說明 ......

    uj5u.com 2020-09-10 00:57:36 more
  • 統計區間素數數量

    1 #pragma GCC optimize(2) 2 #include <bits/stdc++.h> 3 using namespace std; 4 bool isprime[1000000010]; 5 vector<int> prime; 6 inline int getlist(int ......

    uj5u.com 2020-09-10 00:57:47 more
  • C/C++編程筆記:C++中的 const 變數詳解,教你正確認識const用法

    1、C中的const 1、區域const變數存放在堆疊區中,會分配記憶體(也就是說可以通過地址間接修改變數的值)。測驗代碼如下: 運行結果: 2、全域const變數存放在只讀資料段(不能通過地址修改,會發生寫入錯誤), 默認為外部聯編,可以給其他源檔案使用(需要用extern關鍵字修飾) 運行結果: ......

    uj5u.com 2020-09-10 00:58:04 more
  • 【C++犯錯記錄】VS2019 MFC添加資源不懂如何修改資源宏ID

    1. 首先在資源視圖中,添加資源 2. 點擊新添加的資源,復制自動生成的ID 3. 在解決方案資源管理器中找到Resource.h檔案,編輯,使用整個專案搜索和替換的方式快速替換 宏宣告 4. Ctrl+Shift+F 全域搜索,點擊查找全部,然后逐個替換 5. 為什么使用搜索替換而不使用屬性視窗直 ......

    uj5u.com 2020-09-10 00:59:11 more
  • 【C++犯錯記錄】VS2019 MFC不懂的批量添加資源

    1. 打開資源頭檔案Resource.h,在其中預先定義好宏 ID(不清楚其實ID值應該設定多少,可以先新建一個相同的資源項,再在這個資源的ID值的基礎上遞增即可) 2. 在資源視圖中選中專案資源,按F7編輯資源檔案,按 ID 型別 相對路徑的形式添加 資源。(別忘了先把檔案拷貝到專案中的res檔案 ......

    uj5u.com 2020-09-10 01:00:19 more
  • C/C++編程筆記:關于C++的參考型別,專供新手入門使用

    今天要講的是C++中我最喜歡的一個用法——參考,也叫別名。 參考就是給一個變數名取一個變數名,方便我們間接地使用這個變數。我們可以給一個變數創建N個參考,這N + 1個變數共享了同一塊記憶體區域。(參考型別的變數會占用記憶體空間,占用的記憶體空間的大小和指標型別的大小是相同的。雖然參考是一個物件的別名,但 ......

    uj5u.com 2020-09-10 01:00:22 more
  • 【C/C++編程筆記】從頭開始學習C ++:初學者完整指南

    眾所周知,C ++的學習曲線陡峭,但是花時間學習這種語言將為您的職業帶來奇跡,并使您與其他開發人員區分開。您會更輕松地學習新語言,形成真正的解決問題的技能,并在編程的基礎上打下堅實的基礎。 C ++將幫助您養成良好的編程習慣(即清晰一致的編碼風格,在撰寫代碼時注釋代碼,并限制類內部的可見性),并且由 ......

    uj5u.com 2020-09-10 01:00:41 more
最新发布
  • Rust中的智能指標:Box<T> Rc<T> Arc<T> Cell<T> RefCell<T> Weak

    Rust中的智能指標是什么 智能指標(smart pointers)是一類資料結構,是擁有資料所有權和額外功能的指標。是指標的進一步發展 指標(pointer)是一個包含記憶體地址的變數的通用概念。這個地址參考,或 ” 指向”(points at)一些其 他資料 。參考以 & 符號為標志并借用了他們所 ......

    uj5u.com 2023-04-20 07:24:10 more
  • Java的值傳遞和參考傳遞

    值傳遞不會改變本身,參考傳遞(如果傳遞的值需要實體化到堆里)如果發生修改了會改變本身。 1.基本資料型別都是值傳遞 package com.example.basic; public class Test { public static void main(String[] args) { int ......

    uj5u.com 2023-04-20 07:24:04 more
  • [2]SpinalHDL教程——Scala簡單入門

    第一個 Scala 程式 shell里面輸入 $ scala scala> 1 + 1 res0: Int = 2 scala> println("Hello World!") Hello World! 檔案形式 object HelloWorld { /* 這是我的第一個 Scala 程式 * 以 ......

    uj5u.com 2023-04-20 07:23:58 more
  • 理解函式指標和回呼函式

    理解 函式指標 指向函式的指標。比如: 理解函式指標的偽代碼 void (*p)(int type, char *data); // 定義一個函式指標p void func(int type, char *data); // 宣告一個函式func p = func; // 將指標p指向函式func ......

    uj5u.com 2023-04-20 07:23:52 more
  • Django筆記二十五之資料庫函式之日期函式

    本文首發于公眾號:Hunter后端 原文鏈接:Django筆記二十五之資料庫函式之日期函式 日期函式主要介紹兩個大類,Extract() 和 Trunc() Extract() 函式作用是提取日期,比如我們可以提取一個日期欄位的年份,月份,日等資料 Trunc() 的作用則是截取,比如 2022-0 ......

    uj5u.com 2023-04-20 07:23:45 more
  • 一天吃透JVM面試八股文

    什么是JVM? JVM,全稱Java Virtual Machine(Java虛擬機),是通過在實際的計算機上仿真模擬各種計算機功能來實作的。由一套位元組碼指令集、一組暫存器、一個堆疊、一個垃圾回收堆和一個存盤方法域等組成。JVM屏蔽了與作業系統平臺相關的資訊,使得Java程式只需要生成在Java虛擬機 ......

    uj5u.com 2023-04-20 07:23:31 more
  • 使用Java接入小程式訂閱訊息!

    更新完微信服務號的模板訊息之后,我又趕緊把微信小程式的訂閱訊息給實作了!之前我一直以為微信小程式也是要企業才能申請,沒想到小程式個人就能申請。 訊息推送平臺🔥推送下發【郵件】【短信】【微信服務號】【微信小程式】【企業微信】【釘釘】等訊息型別。 https://gitee.com/zhongfuch ......

    uj5u.com 2023-04-20 07:22:59 more
  • java -- 緩沖流、轉換流、序列化流

    緩沖流 緩沖流, 也叫高效流, 按照資料型別分類: 位元組緩沖流:BufferedInputStream,BufferedOutputStream 字符緩沖流:BufferedReader,BufferedWriter 緩沖流的基本原理,是在創建流物件時,會創建一個內置的默認大小的緩沖區陣列,通過緩沖 ......

    uj5u.com 2023-04-20 07:22:49 more
  • Java-SpringBoot-Range請求頭設定實作視頻分段傳輸

    老實說,人太懶了,現在基本都不喜歡寫筆記了,但是網上有關Range請求頭的文章都太水了 下面是抄的一段StackOverflow的代碼...自己大修改過的,寫的注釋挺全的,應該直接看得懂,就不解釋了 寫的不好...只是希望能給視頻網站開發的新手一點點幫助吧. 業務場景:視頻分段傳輸、視頻多段傳輸(理 ......

    uj5u.com 2023-04-20 07:22:42 more
  • Windows 10開發教程_編程入門自學教程_菜鳥教程-免費教程分享

    教程簡介 Windows 10開發入門教程 - 從簡單的步驟了解Windows 10開發,從基本到高級概念,包括簡介,UWP,第一個應用程式,商店,XAML控制元件,資料系結,XAML性能,自適應設計,自適應UI,自適應代碼,檔案管理,SQLite資料庫,應用程式到應用程式通信,應用程式本地化,應用程式 ......

    uj5u.com 2023-04-20 07:22:35 more