设计数据库
后台登陆,要有管理员表
下面是进行thinkphp5.1的操作
先建一个初始化后台管理页面的控制器
注意:
注册用户功能的实现
插件网址:https://packagist.org/
安装命令 composer require phpmailer/phpmailer
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Load Composer's autoloader
require 'vendor/autoload.php';
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('[email protected]', 'Mailer');
$mail->addAddress('[email protected]', 'Joe User'); // Add a recipient
$mail->addAddress('[email protected]'); // Name is optional
$mail->addReplyTo('[email protected]', 'Information');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
// Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
注意:
重置用户密码功能
重置用户密码;通过邮箱给客户发送验证码,客户发送验证码以后,会在邮箱接收新的密码,然后就可以登陆了
注意:
登陆成功以后,会进入home控制器下的index方法
后台模板的继承实现
登陆成功以后,会进入home控制器的index方法,然后跳转到后台管理页面
下面是新建home控制器
home控制器的index方法用来显示后台页面
1,先判断有登陆,防止重复登录的方法
上面方法是判断有登陆,不能让他再进入登陆页面了,下面是判断没有登陆,然后让他进入登陆页面
用户退出功能实现