首頁 > php框架 > ThinkPHP > 主體

thinkphp5最完美的註冊登入

爆肝混世大魔王-流笙 第五人格服务
發布: 2021-03-15 09:02:15
原創
144 人瀏覽過

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&gt ; ";<p></p> $this->assign( [ 'email' => $c,<p></p> 'q' => $q,<p></p> 'h' => $h ,<p></p> ] );<p></p> return $this->fetch( 'user/dlhdym' );<p></p> }<p></p> }別的 {###<p> 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"/}



  验证码:

 

{$title|default="首页"}

 

   

 

   

 

 

 

   

相關標籤:
1
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
最新問題
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!