PHP-Graduation Project of Online Learning and Teaching Resources Station--[White Project]

Skills are here
How to learn PHP – [Knowledge scope of mind map]
More projects are here
Design and implementation of jsp-based tourism website in Saibei villages and towns – [Graduation thesis]

This series of school motto

Use the free public video to fly to the training class! If you are beaten to death, you will not report to work, and you will make money by working hard!
If other people want to prostitute for free, they can find Fan Debiao online! There are thousands of IT roads, but there is only one way to success!
---------- It is reasonable for others to go whoring for free, but that is what Sajia thinks highly of. If the project is not good, Tianjin Baozigou will ignore it!

Technology used in this project

PHP classless PHP class writing ThinkPHP framework other frameworks
*

environment

PHP version mysql version run tool editing tools
5.5.38+Apache 5.5 (phpstudy comes with it) phpstudy2018 phpStorm 2018

front page

insert image description here

Notice:
If there is a warning code above,
directly modify the php.ini file configuration


The method of closing php.ini warning: first find and open the php.ini configuration file; then modify the content to "display_errors=Off"; finally save the modification.

After modifying the code, there is no annoying warning message.

A little trick, you can set one in phpstudy to turn off the warning, and the other to turn on the warning. When debugging, switch to open the warning, and wait for the development to be completed, and then use the PHP version that closes the warning. It smells so good!

Garbled problem

Some projects will have garbled characters when opening. Originally, this would not be a problem if hbuilder was used. In fact, it is not a big problem to use phpstorm 2018, just follow the prompts and click OK.
If you want to set it, here it is.
insert image description here

off-topic episode

If mysql conflicts. I found an article about uninstalling mysql

Super detailed tutorial on uninstalling mysql (follow the steps to completely uninstall) Update time: March 23, 2023 09:45:40 Author: code cloud iron fan There are really
many problems that mysql is not uninstalled cleanly like vmware, which makes some friends I want to reinstall the system. It’s okay. Let me tell you how to uninstall mysql cleanly. The following article mainly introduces the ultra-detailed tutorial on uninstalling mysql. You only need to follow the steps to completely uninstall it. Friends who need it can refer to the right click
【 Computer], select [Management], open the "Computer Management" interface,
insert image description here
select [Services] in [Services and Applications], find [mysql] on the right, right-click, and select [Stop] Step 2
insert image description here
: Uninstall the mysql software
in the control Uninstall in the panel, uninstall all mysql-related, and uninstall the mysql installation package. After a while, re-download the installation package. 1. After uninstalling, delete
C:\Program Files (x86)\MySQL file, delete the mysql folder as well
2. Delete the HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Services\Eventlog\Application\MySQL folder, if not, you don’t need to delete it.
3. Delete all the files in C:\ProgramData\MySQL under the C disk. If you can’t delete them, you can use 360 ​​to smash them. The programData file is hidden by default, and it will be visible after setting the display. 4. The key
! ! ! ! Delete the folder under C:\Documents and Settings\All Users\Application Data\MySQL. Be sure to delete it. You can copy and paste directly, and you will see this folder. 5 Note: This step is the most cumbersome and the most
critical , many people cannot reinstall successfully because the registry information has not been cleaned up in this step.
1. Windows+R to run the "regedit" file, open the registry
2. Delete the registry: HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog\Application\MySQL folder, open one by one according to this path
so that you can reinstall the MySQL software ! Part two:

Completely delete the mysql method

1. First, stop the MySQL service in the service (Start->Control Panel->Administrative Tools->Service). Open the Control Panel - Add and Remove Programs, find MySQL, and uninstall it. Or use 360 ​​Security Guard to uninstall it. You can also use the installation program of mysql to delete

2. Uninstall the installed MYSQL, but this is only half of the uninstallation of MySQL, and the important other half is to clean up the registry. We want to enter the registry and enter regedit in Start-Run to open the registry

3. Find the items about MYSQL and delete them all. You need to search item by item and delete them all, so that it can be installed during installation. In fact, the MySQL entries in the registry are these three items:

HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Services/Eventlog/Application/MySQL
HKEY_LOCAL_MACHINE/SYSTEM/ControlSet002/Services/Eventlog/Application/MySQL
HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Eventlog/Application/MySQL

4. Also delete the my.ini file under C:/WINDOWS!

In this way, after deleting the above four items, MySQL is basically completely uninstalled. If you are still not at ease, you can search for mysql on the C drive and delete all related items.

SQL92 Standard Overview
SQL (Structured Query Language) is a language used to manage relational databases, which includes three aspects: data definition, data manipulation and data query. SQL92 is an SQL standard formulated by the American National Standards Institute (ANSI) and the International Organization for Standardization (ISO) in 1992, and is the second-generation standard of the SQL language. The SQL92 standard has become a common standard for relational databases, and almost all major relational databases have implemented this standard.
A series of specifications are defined in the SQL92 standard, including various aspects such as data types, operators, functions, stored procedures, triggers, and views. The main purpose of the SQL92 standard is to define a basic SQL operating language, which greatly simplifies the difficulty of querying and writing SQL for application developers.
Second, the main features of the SQL92 standard
The SQL92 standard contains many important features, some of which are as follows:
1. Support data storage and query based on the relational model
The SQL92 standard supports data storage and query based on the relational model. This data model is Consists of independent tables and relationships between tables. Applications can add, delete, modify and query data in tables through SQL statements.
2. Standardized SQL syntax
The SQL92 standard defines a standardized SQL syntax, which makes SQL query statements common among different database management systems and greatly enhances data portability. In the SQL92 standard, any standard-compliant SQL query statement can be executed on any standard-compliant database management system.
3. Support transaction processing
The SQL92 standard supports transaction processing. A transaction refers to a group of associated database operations. These operations either all succeed or all fail. Through transaction processing, you can ensure that the database maintains consistency, reliability, and security while performing any critical operation.
4. Support data integrity constraints
The SQL92 standard supports data integrity constraints, which can enforce changes to the database under certain conditions, thereby guaranteeing the integrity and accuracy of the database. These constraints can be defined on specific columns, tables, databases or the entire database, such as uniqueness, non-nullness, foreign keys, etc.

necessary project knowledge

Many people think that PHP recruits fewer people because PHP has produced fewer projects. In fact, they really misunderstood. It’s just that the small projects of PHP are used by few people and do not need to be upgraded or maintained, so PHP employs fewer people, but if you really look at the many paid small software in your mobile phone, PHP is probably more than JAVA Woolen cloth.
It is said that some individuals are now looking for videos to launch. If you look at their own small websites, it is estimated that PHP is still the majority.

PHP

PHP (PHP: Hypertext Preprocessor) is a "hypertext preprocessor", which is a scripting language executed on the server side, especially suitable for Web development and can be embedded in HTML. PHP grammar learned C language, absorbed the characteristics of multiple languages ​​​​of Java and Perl to develop its own characteristic grammar, and continued to improve and improve itself according to their strengths, such as java's object-oriented programming. The main goal of this language was to make Developers write high-quality web sites quickly. [1-2] PHP supports both object-oriented and process-oriented development, and is very flexible in use.
PHP is an open source software project with many developers. It was originally an abbreviation of Personal Home Page and has been officially renamed "PHP: Hypertext Preprocessor". PHP was created by Rasmus Lerdorf in 1994 [30], originally just a simple program written in Perl language to count the number of visitors to his own website. Later, it was rewritten in C language, and at the same time, it could access the database. In 1995, PHP (Personal Home Page Tools) published the first version of PHP1. Since then, more and more websites have begun to use PHP, and there is a strong demand to add some features, such as loop statements and array variables, etc. PHP2 released in 1995 added support for mySQL.
As a high-level language, PHP language is characterized by open source. It belongs to the C language system in terms of design system. It allows many beginners who have received higher education to quickly accept and complete the introductory learning. It is easy to use and easy to find a job. Natural fans many. If the amount of data is large and the access pressure is high, technical solutions such as redis, mysql sub-table partition sub-database, elasticsearch search engine, message queue write protection and distributed cluster deployment of php system can be integrated to alleviate data storage, service access and data retrieval. of great pressure.
Regardless of whether it is a large, medium or small project, PHP is a very suitable high-level programming language. Whether it is suitable depends on the mastery of the project development team. But for larger and more complex projects, the most common php-fpm programming model shows its weakness. Aiming at a series of shortcomings exposed by PHP-fpm, the simplest and most reliable solution is to upgrade compatible PHP versions in time. Compared with PHP5.6, PHP7.0.0 [14] improves performance by 2 times. In addition, the Preloading provided by PHP7.4 The preloading mechanism [11] realizes the resident memory of some programs and obtains a good performance improvement. In PHP8, it also provides efficient JIT (Just-In-Time Just-In-Time Compilation) [12] computing support. In addition, developers with a higher level can turn to more difficult php-cli programming, which can solve most system performance problems. Both PHP7 and PHP8 support this mode of programming.

performance improvement
The higher the PHP version, the higher its overall performance. According to the official introduction,
the performance of PHP7.0.0 [14] is 2 times higher than that of PHP5.6. PHP7.4 is about 30% faster than PHP7.0, and PHP8.0 is in The performance has been improved by about 10% relative to PHP7.4. PHP
8.0 introduces the JIT compiler feature, while adding a variety of new language features, such as named parameters, union types, annotations, Constructor Property Promotion, match expressions, nullsafe operators,
and improvements to the type system, error handling, and consistency . PHP has its own core development team, and maintains the frequency of releasing a major version every five years and two minor versions every month. The latest version is PHP8.08 [
15]. PHP 7.0.0 [16] was released on 2015-12-03, the latest version under this version is PHP 7.4.21
[18] (release date: 2021-07-01), PHP 8.0.0 [17] was released on 2020- 11-26, the latest version under this version is PHP
8.0.8 (release date: 2021-07-01).

ThinkPHP

ThinkPHP is an open source lightweight PHP framework born to simplify enterprise-level application development and agile WEB application development.
ThinkPHP is a fast, compatible and simple lightweight domestic PHP development framework. It was born in early 2006, formerly known as FCS, and officially changed its name to ThinkPHP on New Year's Day in 2007. It was released under the Apache2 open source protocol, transplanted from the Struts structure and made improvements and improvements. , At the same time, it also draws on many excellent foreign frameworks and patterns, uses object-oriented development structure and MVC pattern, integrates the idea of ​​Struts and TagLib (tag library), RoR ORM mapping and ActiveRecord pattern.
ThinkPHP can support windows/Unix/Linux and other server environments. The official version requires support of PHP5.0 or above, and supports MySql, PgSQL, Sqlite databases and PDO extensions. The ThinkPHP framework itself has no special module requirements, and the specific application system operating environment Requirements depend on the modules involved in the development.
On
December 11, 2015, ThinkPHP 5.0 Beta was released; on
February 27, 2017, the full version of Thinkphp5.0.5 was officially released [3]; on
May 2, 2018, the Thinkphp5.1.0RC version was released; [4]
2019 On April 22, 2019, version Thinkphp6.0RC2 was released [5]; on
August 16, 2019, version Thinkphp6.0RC4 was released [6]; on
December 24, 2019, version Thinkphp6.0.1 was released [7];

ThinkPHP MVC

Easy to use
Model (M): The definition of the model is completed by the Model class. The Model class is located in the LibModel directory under the project directory.
Controller (C): Both the application controller (core controller) and the Action controller assume the role of the controller. The difference is that the Action controller completes the business process, while the Application controller (App class) is responsible for scheduling control. The Action controller is located in the LibAction directory under the project directory.
View (V): The implementation of the template has nothing to do with the framework, it is 100% separated, and can be previewed and produced independently. The template directory is located in the Tpl directory under the project directory.

ThinkTemplate

ThinkTemplate is a compiled template engine that uses XML tag library technology, supports two types of template tags, uses dynamic compilation and caching technology, and supports custom tag libraries. Its features include:
1) Support mixed definition of XML tag library and ordinary tags;
2) Compile once, and run directly next time without recompiling;
3) After the template file is updated, the template cache is automatically updated;
4) Automatically load the current operation Template cache file, no need to specify template file name;
5) Support code conversion and Content-Type replacement;
6) Template variable output prefix support, avoid variable name conflict;
7) Template constant replacement, no need to set template variable;
8) Support variable combination Regulator and formatting functions;
9) Support for replacing other template engine plug-ins;
10) Support for obtaining template page content.

ThinkPHP 6 and ThinkPHP 5

Compared with ThinkPHP 5, ThinkPHP 6 has the following major changes and improvements:

  1. Better performance: ThinkPHP 6 adopts a more efficient underlying framework with better performance and higher concurrency. At the same time, ThinkPHP 6 also uses coroutine technology, which can handle a large number of requests more efficiently.
  2. More concise code: ThinkPHP 6 introduces a more concise syntax, which allows developers to write code more easily. At the same time, ThinkPHP 6 also supports more elegant chain operations, which can make the code more concise and easy to read.
  3. More flexible routing: The routing system of ThinkPHP 6 is more flexible and can support richer routing rules and parameter configurations. At the same time, ThinkPHP 6 also supports automatic routing, which allows developers to configure routing more conveniently.
  4. More convenient template engine: ThinkPHP 6 adopts a more convenient template engine, which allows developers to write templates more easily. At the same time, ThinkPHP 6 also supports template layout and template inheritance, which allows developers to design templates more conveniently.
  5. More complete documentation: The documentation of ThinkPHP 6 is more complete, including more detailed API documentation and usage instructions, which can make it easier for developers to get started and use.

In short, ThinkPHP 6 has many improvements and optimizations compared to ThinkPHP 5, which allows developers to develop more efficiently. At the same time, ThinkPHP 6 also maintains the advantages of ThinkPHP 5, such as excellent scalability and rich functional modules, which can meet various business needs.
insert image description here
Compared with
the front page framework (Thymeleaf) of springBoot MVC (SpringMVC)OM (mybatis),
insert image description here
whether it is GIT or GITEE, there are really many projects that cannot run on it. It's not that you can run open source projects.

phpStudy settings

The website directory cannot contain Chinese characters or spaces, so just obediently use the variable name
thinkphp that can be recognized by the C language. Be sure to pay attention to the directory. This project sets the arrow pointing to "website directory"
Whether the thinkPHP project can run is mostly due to the problem of the directory and the version of PHP.
insert image description here

import database

Open mysql-front or navicat
Note: Database name: jiaoda Super user: root Password: 123456
Just run the attachment in this example. The screenshot of the successful import of the database is as follows:
insert image description here

display page

Pages are too simple. Originally, I wanted to add a software such as a photo album to process it, but then I found that it was not on the computer. Let's have a beautiful picture show, the original one is too ugly. But it seems that students' homework has this trend.
insert image description here

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

Backstage:

Background link: http://127.0.0.1/admin/login/index.html Login account: admin Login password: 111111

insert image description here
insert image description here

database table structure

insert image description here

The project directory is shown in the figure:

insert image description here

code part:

connect database

<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <[email protected]>
// +----------------------------------------------------------------------

return [
    // 数据库类型
    'type'            => 'mysql',
    // 服务器地址
    'hostname'        => '127.0.0.1',
    // 数据库名
    'database'        => 'e_learning',
    // 用户名
    'username'        => 'root',
    // 密码
    'password'        => '123456',
    // 端口
    'hostport'        => '3306',
    // 连接dsn
    'dsn'             => '',
    // 数据库连接参数
    'params'          => [],
    // 数据库编码默认采用utf8
    'charset'         => 'utf8',
    // 数据库表前缀
    'prefix'          => 'tb_',
    // 数据库调试模式
    'debug'           => true,
    // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
    'deploy'          => 0,
    // 数据库读写是否分离 主从式有效
    'rw_separate'     => false,
    // 读写分离后 主服务器数量
    'master_num'      => 1,
    // 指定从服务器序号
    'slave_no'        => '',
    // 自动读取主库数据
    'read_master'     => false,
    // 是否严格检查字段是否存在
    'fields_strict'   => true,
    // 数据集返回类型
    'resultset_type'  => 'array',
    // 自动写入时间戳字段
    'auto_timestamp'  => false,
    // 时间字段取出后的默认时间格式
    'datetime_format' => 'Y-m-d H:i:s',
    // 是否需要进行SQL性能分析
    'sql_explain'     => false,
];


home page controller

<?php
namespace app\index\controller;
use think\Controller;
use think\Request;
use app\index\model\LearnRecord;
use app\index\model\DownloadRecord;

class Index extends Controller
{
    
    
	
	public function _initialize(){
    
    
        
        $request = Request::instance();
        $controller = $request->controller();
        $action = $request->action();
		$this->assign('controller',$controller);
        $this->assign('action',$action);
    }
	
	//首页
    public function index()
    {
    
    	   
	   //精彩课程
	   $datas = db('course')->where('status',1)->order('sort desc,id desc ')->select();
	   $this->assign('datas',$datas);
	   $resourceTotal = db('resource')->where('status',1)->count();
	   $this->assign('resourceTotal',$resourceTotal);
	   return view();
    }
	
	//列表
    public function lists()
    {
    
    	   
	   //课程id
	   $id = input('id');
	   if(empty($id)){
    
    
		   $this->error('参数错误');
	   }
	   $datas = db('resource')->where('course_id',$id)->where('status',1)->order('sort desc,id desc')->select();
	   $this->assign('datas',$datas); 
	   return view();
    }
	
	//详情页
    public function view(){
    
     
      		
		$id = input('id');				
	    $result = checkRoot($id);
	    if(!$result){
    
    
		   $this->error('请您先登录!');
	    }
		
		$info = db('resource')->where('id',$id)->where('status',1)->find();
		if(empty($info)){
    
    
		   $this->error('参数错误');
		}
		$this->assign('info',$info);
		
		//课程名称
		$courseName = db('course')->where('id',$info['course_id'])->value('name');
		$this->assign('courseName',$courseName);
			
		// 目录内容
		$catalogs  = db('resource')->where(array('course_id'=>$info['course_id']))->where('status',1)->field('id,title')->order('sort desc ,id desc')->select();		
		$this->assign('catalogs',$catalogs); 
		
		$type = input('type',1);
		if($type==2){
    
    
		   $content = $info['document'] ? htmlspecialchars_decode($info['document']) : '<center>暂无内容,敬请期待!</center>';
		   $this->assign('content',$content);
		}
		$this->assign('type',$type);
		
		//观看记录
		$user_id = session('user_id');
		if($user_id){
    
    
			$record_info = db('learn_record')->where('user_id',$user_id)->where('resource_id',$id)->find();
			if(empty($record_info)){
    
    
				$dataArr = array(
				    'user_id' => $user_id,
					'course_id' => $info['course_id'],
					'resource_id' => $id,
					'addtime' => date('Y-m-d H:i:s')
				);
				model('learn_record')->save($dataArr);
			}else{
    
    
				model('learn_record')->where('id',$record_info['id'])->update(['addtime' => date('Y-m-d H:i:s')]);
			}
		}			
		
		//上、下一节
		$ids = db('resource')->where(array('course_id'=>$info['course_id']))->where('status',1)->order('sort desc,id desc')->column('id');
		$uid = $this->up_down( $id , $ids , 'up');	
		$did = $this->up_down( $id , $ids , 'down');
		$index = array_search($info['id'],$ids);	
		$this->assign('uid',$uid);
		$this->assign('did',$did);
		$this->assign('index',$index+1);
					
		return view();	
    }
	
	//源码下载
	public function downloadCode(){
    
    
	        		
		$id = input('id',0,'int');
		$result = checkRoot($id);
	    if(!$result){
    
    
		   $this->error('请您先登录!');
	    }
		//源码信息		
		$info = db('resource')->where('id',$id)->where('status',1)->find();	
		if(empty($info) || empty($info['code_path'])){
    
    
		   $this->error('参数有误!'); 
		   exit;
		}		
		
		//下载记录
		$user_id = session('user_id');
		if($user_id){
    
    			
			$record_info = db('download_record')->where('user_id',$user_id)->where('resource_id',$id)->find();
			if(empty($record_info)){
    
    
				$dataArr = array(
					'user_id' => $user_id,
					'course_id' => $info['course_id'],
					'resource_id' => $id,
					'addtime' => date('Y-m-d H:i:s')
				);
				model('download_record')->save($dataArr);
			}else{
    
    
				model('download_record')->where('id',$record_info['id'])->update(['addtime' => date('Y-m-d H:i:s')]);
			}
		}
		
		//保存路径 
		$save_path = "./public/uploads/code/".$info['code_path'];
		$title = autoCharset($info['title'],'utf-8','gbk');
		$find  = array(' ','<','>');
		$title = str_replace($find,'',$title);
		
		//开始下载
		$file = fopen($save_path,"r");
		header("Content-type:application/octet-stream");
		header("Content-Length:".filesize($save_path));
		header("Content-Disposition:attachment;filename=".$title.strrchr($info['code_path'],'.'));
		readfile($save_path);
		fclose($file);
		exit;	
	}
	
	//上、下一节
	private function up_down( $id , $arr , $flag){
    
    
			
		$arr_key_max = count($arr)-1;
		$id_key = array_search($id,$arr);
		
		if($flag=="up"){
    
    
		   $uid = ($id_key==0) ? false : $arr[$id_key-1];		  
		   return $uid;
		}
		if($flag=="down"){
    
    
		   $did = ($id_key==$arr_key_max) ? false : $arr[$id_key+1];
		   return $did;
		}
		
	}
	
	
	//登录页面
	public function login()
	{
    
    
	   if(session('user_id') || session('username')){
    
    
	      $this->redirect('Index/user');
	   }else{
    
    
	      return view();
	   }
	}
	
	//登录验证
	public function chkLogin()
	{
    
    
	   if(request()->isAjax()){
    
    
			if(session('qavalue') != input('iQapTcha')){
    
    
			    $res['status'] = false;
                $res['msg'] = '请滑动滑块!';
			}else{
    
    								 
				$member = model('Member');
				$num = $member->login(input('post.')); 				
				if($num==1){
    
    
					$res['status'] = true;
					$res['msg'] = url('Index/index');
				}elseif($num==2){
    
    
					$res['status'] = false;
					$res['msg'] = '密码错误!';
				}elseif($num==3){
    
    
					$res['status'] = false;
					$res['msg'] = '用户不存在!';
				}
			}
        }else{
    
    
		    $res['status'] = false;
            $res['msg'] = '请求错误~';
		}
		return json($res);
	}
	
	// 滑块初始化
	public function setQapTcha()
	{
    
          
       session('qavalue',input('pass'));        
    }
	
	// 校验滑块
	public function checkSlider()
	{
    
    
        $aResponse['error'] = false;
        session('iQaptcha',false);

        if(isset($_POST['action'])){
    
    
            if(htmlentities($_POST['action'], ENT_QUOTES, 'UTF-8') == 'qaptcha'){
    
    
                session('iQaptcha',true);
                if(session('iQaptcha')){
    
    
                    $aResponse['val'] = session('qavalue');
                    return json($aResponse);
                }else{
    
    
                    $aResponse['error'] = true;
                    return json($aResponse);
                }
            }else{
    
    
                $aResponse['error'] = true;
                return json($aResponse);
            }
        }else{
    
    
            $aResponse['error'] = true;
            return json($aResponse);
        }
    }
	
	//注册页面
	public function regist()
	{
    
    
	   if(session('user_id') || session('username')){
    
    
	      session(null); 
	   }
	   return view();	   
	}
	
	//保存用户
	public function saveMember()
	{
    
    
	   if(request()->isAjax()){
    
    
			if(!captcha_check(input('code'))){
    
    
			    $res['status'] = false;
                $res['msg'] = '验证码错误~';
			}else{
    
    				
				$post = input('post.');  			         				
				// 验证表单
				$validate = \think\Loader::validate('Member'); 
				if(!$validate->scene('save')->check($post)){
    
      
					$res['status'] = false;
					$res['msg'] = $validate->getError(); 
					return json($res);               
				}
				$data = array(
				    'username' => $post['username'],
					'password' => md5(sha1($post['password'])), 
					'addtime'  => time(),
				);
				//$member = new Member(); 
				$member = model('Member');
				$result = $member->save($data); 
				if($result){
    
    
				    session('user_id', $member->id);
                    session('username', $post['username']);
					$res['status'] = true;
					$res['msg'] = url('Index/index');
				}else{
    
    
					$res['status'] = false;
					$res['msg'] = '保存失败!';
				}
			}
        }else{
    
    
		    $res['status'] = false;
            $res['msg'] = '请求错误~';
		}
		return json($res);	
	}
	
	//退出
	public function logout(){
    
    
        session('user_id',null); 
		session('username',null); 
        $this->redirect('Index/index');
    }
	
}

Home VIEW

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">	
<meta name="keywords" content="明日科技,thinkphp5.0,编程e学网" />
<meta name="description" content="明日科技,thinkphp5.0,编程e学网" />
<title>编程e学网</title>
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="__INDEX__/css/public.css" />
<link rel="stylesheet" type="text/css" href="__INDEX__/css/index.css" />
</head>
<body>  
    <div id="preloader">
        <div id="preloader-inner"></div>
    </div>  
    {
    
    include file="public/top"/}    		
	<div class="lightball">       
        <div class="clubTit">
        	<img src="__INDEX__/images/banner.png">
        	<a href="javascript:" class="signIn">立即学习</a>        	
        </div>
        <div class="banner_btn"><img src="__INDEX__/images/btn2.png"></div>
        <div class="light-bottom"></div> 
    </div>    
    <!--中间课程部分-->
    <div class="content">
    	<div class="plat">
			<div class="zero">
				<div class="zero_title">
					<p class="bigsize"><span class="color_red">精彩课程</span></p>
					<p class="small_size margin_t"><span class="margin_r">{
    
    $datas|count}</span> <span class="margin_r"> {
    
    $resourceTotal} 小节</span> {
    
    notempty name="datas"}学习时长 {
    
    $resourceTotal/5|ceil}{
    
    /notempty}</p>
				</div>
				<div class="zero_list">
                  {
    
    notempty name="datas"}
                   {
    
    foreach name="datas" item="item"}
					<div class="list_infor">         
                        <a href="{:url('lists',['id'=>$item.id])}"><img src="__UPLOADS__/image/{$item.image_path}" onerror="this.src='__INDEX__/images/no_image.jpg'"></a>
						<a href="{:url('lists',['id'=>$item.id])}"><p class="small_size font_weight margin_l" title="{$item.name}">{
    
    $item.name}</p></a>    
						<div class="infor_list">
							<p class="icon_1">{
    
    $item.id|getResourceTotal}小节</p>
							<p class="icon_2">{
    
    $item.id|getCourseLearnerTotal}人观看</p>
						</div>
					</div>               				
				   {
    
    /foreach}
                  {
    
    else/}
                    <center>暂无课程</center>
                  {
    
    /notempty}
				</div>
			</div>
		</div>
	</div>   
    {
    
    include file="public/foot"/}
    <script type="text/javascript" src="__INDEX__/js/idangerous.swiper.min.js"></script>
    <script type="text/javascript" src="__INDEX__/js/jquery.preloader.min.js"></script>		
    <script type="text/javascript" src="__INDEX__/js/three.js"></script>	
    <script type="text/javascript" src="__INDEX__/js/Projector.js"></script>	
    <script type="text/javascript" src="__INDEX__/js/CanvasRenderer.js?v1"></script>	
    <script type="text/javascript" src="__INDEX__/js/light.min.js?v2"></script>
    <script type="text/javascript">
       $(window).scroll(function(event){
    
    
          if($(window).scrollTop() >= 920){
    
    
		     $(".top-nav").removeAttr("style").addClass('fix');
		  }else{
    
    
		     $(".top-nav").css('position','absolute').removeClass('fix');
		  }
       });
	   $(window).preloader({
    
    
		   delay: 0.1
	   });
	   $(function(){
    
    
		  $('.signIn').click(function(){
    
    
		     //$(window).scrollTop(920);
			 $('html,body').animate({
    
    scrollTop: '920px'}, 600);
		  });
	   });
    </script>   		
</body>
</html>

Other pages download the resource pack by themselves

reference

Design and Implementation of Saibei Villages and Towns Tourism Website Based on JSP – [Graduation Thesis]
https://blog.csdn.net/dearmite/article/details/131962993

supporting resources

PHP-Graduation Project of Online Learning and Teaching Resources Station – [White Project]
https://download.csdn.net/download/dearmite/88168948

Operation:

Build the project and complete other functions that you think of. Learning PHP is to be willful and do whatever you want.
Only magic can defeat magic!
insert image description here

Guess you like

Origin blog.csdn.net/dearmite/article/details/132112316