namespace app\index\controller;
use app\common\controller\Base; //導入控制器公用
use think\ Db;
use app\index\model\Add as AddModel;
use think\Validate;
use think\Session;
use think\facade\Url;
class Index extends Base {
public
function index() {
$s = cookie( 'email' );
if ( is_null( $s ) ) {
return $this->fetch();
} else {
$q = '親愛的使用者名稱信箱為';
$h = '歡迎回來';
$this->assign( [ '電子郵件' => $s,
'q' => $q,
'h' => $h,
] );
return $this->fetch( 'user/dlhdym' );
}
# }
}
####命名空間app\index\controller;
使用think\Controller;
使用app\common\Validate;
使用app\common\controller\Base ;
use app\ common\ model\ User 作為UserModel;
class User extends Base {
//註冊頁面
public
# function register( ) {
$this->assign( [ 'title' => '使用者註冊' ] );
return $this->fetch();
## } public function insert() { //接受資料 $data = input( 'post.' );# $c = $_POST[ '電子郵件' ]; $d = $_POST[ '手機' ]; $code = $_POST[ '代碼' ]; $c = UserModel::get( [ 'email' =>; $_POST[ '電子郵件' ] ] ); $d = UserModel::get( [ '移動' => $_POST[ '移動' ] ); $h = is_null( $c ); $z = is_null( $d ); if ( $h $z != 2 ) {# echo "<script>; alert('您好你要註冊的郵箱或手機號,平台裡已經有人註冊過了請換一下信息吧');</script>"; return $this->fetch( '使用者/註冊' ); } if ( !captcha_check( $code ) ) { echo "<script>alert('您沒有輸入驗證碼或驗證碼錯誤! _POST[ 'mobile' ];<p> if ( preg_match( "/^1[34578]{1}\d{9}$/", $sjh ) ) {} else {<p> echo "<script>alert('不是手機號碼!');</script>"; return $this->fetch( '用戶/註冊' );exit; } //實例化驗證器 $validate = new\ app\ common\ validate\ User; / /進行資料驗證 if ( $validate->check( $data ) ) { $data = input( 'post.' ); unset( $ data[ 'password_confirm' ] ) ; $user = new UserModel( $data ); $a = $user->allowField( [ '姓名', '電子郵件', '移動', '密碼' ] )->save(); if ( $a = 1 ) {# $code = input( 'code' ); echo "<script>alert ('註冊成功請登入看看吧!');</script>"; return $this->fetch( 'user/login' );
## }
# } else {
dump( $validate->getError() );
}
return $this- >fetch( 'user/register' );
}
//使用者登入
public
function login() {
$this->指派( [ '標題' =>; '使用者登入' ] );
return $this->fetch( 'user/login' );
}
public
function loginCheck ( ) {
if ( isset( $_POST[ 'email' ] ) ) {} else {
echo "<script>alert('請不要動網址列!'); < /script>";</script>
return $this->redirect( 'index/index/index' );
exit;
}
$a = UserModel::get( [ 'email' => $_POST[ 'email' ] ] );
$b = UserModel::get( [ '密碼' => $_POST[ '密碼' ] ] );
$c = $_POST[ '電子郵件' ];
$d = $_POST[ '密碼' ];
$e = is_null( $a );
$f = is_null( $b );
if ( $c != '' && $d != '' ) {
if ( $f $e != 1 ) {
cookie( 'email', $c, 900000 ); // 指定cookie保存時間
$s = cookie( 'email' );
if ( $s = cookie( 'email' ) ) {
## $q = '親愛的使用者名稱信箱為'; $h = '回饋'; echo "<script>alert('現在已經登入了!');</script>> ; "; $this->assign( [ 'email' => $c, 'q' => $q, 'h' => $h , ] ); return $this->fetch( 'user/dlhdym' ); } }別的 {###echo "<script>alert('邮箱或密码错误');</script>";
return $this->fetch( 'user/login' );
}
} else {
echo "<script>alert('您还没有输入邮箱或密码');</script>";
return $this->fetch( 'user/login' );
}
}
}
namespace app\ index\ controller;
use think\ Controller;
use think\ facade\ Url;
use think\ Cookie;
class tt extends Controller {
public
function index() {
cookie::delete( 'email' );
return $this->fetch( 'index/index' );
}
}
{include file="public:header"/}
{include file="index:nav"/}
全部问答
{include file="public:right"/}
{include file="public:footer"/}
{include file="public:header"/}
{include file="public:nav"/}
用户注册
{include file="public:right"/}
{include file="public:footer"/}
{include file="public:header"/}
{include file="public:nav"/}
用户登录
{include file="public:right"/}
{include file="public:footer"/}
以上是thinkphp5最完美的註冊登入的詳細內容。更多資訊請關注PHP中文網其他相關文章!

本文討論了ThinkPHP的內置測試框架,突出了其關鍵功能(例如單元和集成測試),以及它如何通過早期的錯誤檢測和改進的代碼質量來增強應用程序可靠性。

本文討論了在無服務器體系結構中使用ThinkPHP的關鍵注意事項,專注於性能優化,無狀態設計和安全性。它突出了諸如成本效率和可擴展性之類的收益,但也應對挑戰

本文討論了在ThinkPHP微服務中實施服務發現和負載平衡,重點是設置,最佳實踐,集成方法和推薦工具。[159個字符]

ThinkPHP的IOC容器提供了高級功能,例如懶惰加載,上下文綁定和方法注入PHP App中有效依賴性管理的方法。Character計數:159

ThinkPHP具有輕巧的設計,MVC架構和可擴展性。它通過各種功能提高可擴展性,加快開發並提高安全性。

本文概述了使用ThinkPhp和RabbitMQ構建分佈式任務隊列系統,重點是安裝,配置,任務管理和可擴展性。關鍵問題包括確保高可用性,避免常見的陷阱,例如不當


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 Linux新版
SublimeText3 Linux最新版

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

Atom編輯器mac版下載
最受歡迎的的開源編輯器