Why does my section if(result === true){} not respond as soon as I open the comment webpage?
城南旧事随风落
城南旧事随风落 2018-03-06 23:25:50
0
5
1518

<?php

namespace app\index\controller;

use app\index\controller\Base;

use think\Request;

use app\index\model\User as UserModel;


class User extends Base

{

//Login page

public function login()

{

return $this -> view ->fetch();

}

//Login verification

public function checklogin(Request $request)

{

//Initial return parameters

$status = 0;

$result = '';

$data = $request -> param();

//Create validation rules

$rule = [

'name|Username' => 'require',//Username is required

'password|Password' => 'require',

'verify|captcha' => 'require|captcha',

];

$msg = [

'name ' => ['require'=>'Username cannot be empty! '],

'password' => ['require'=>'Password cannot be empty! '],

'verify' => [

'require'=>'Verification code cannot be empty! ',

'captcha'=>'Verification code error',

],

];

$result = $this->validate($data, $rule, $msg);

if($result ===true){

//Construct query conditions

$map = [

'name' => $data['name'],

'password' => md5 ($data['password']),

];

//Query user information

$user = UserModel::get($ map);

if($user == null){

$result = 'The user was not found';

}else{

$status = '1';

$result = "Verification passed";

}

}

return ['status '=>$status, 'message'=>$result, 'data'=>$data];

}

//Log out

public function logout()

{

         

  }

}


##

城南旧事随风落
城南旧事随风落

reply all(3)
轻微强迫症

Mine is the same, has the poster solved it? Can you share it

段旭涛

QQ截图20180307101617.png
When there is a syntax error in any method in a PHP class, other methods cannot be used normally.
It is recommended to pay attention to Chinese and English symbols when writing code.

城南旧事随风落

The login page cannot be accessed

  • reply $result = 'The user was not found'; The semicolon here is written in Chinese When an error is reported on the page, other methods will also cause problems.
    段旭涛 author 2018-03-07 10:19:18
  • reply Have you solved it? I've reached this point too.
    刀刀 author 2020-01-02 10:12:59
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template