Home  >  Q&A  >  body text

Why does my section if(result === true){} not respond as soon as I open the comment webpage?

<?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()

{

         

  }

}


##

城南旧事随风落城南旧事随风落2391 days ago1440

reply all(5)I'll reply

  • 轻微强迫症

    轻微强迫症2018-05-25 11:08:27

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

    reply
    0
  • 段旭涛

    段旭涛2018-03-07 10:28:31

    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.

    reply
    0
  • 城南旧事随风落

    城南旧事随风落2018-03-06 23:33:05

    The login page cannot be accessed

    reply
    0
  • 段旭涛

    $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.

    段旭涛 · 2018-03-07 10:19:18
    刀刀

    Have you solved it? I've reached this point too.

    刀刀 · 2020-01-02 10:12:59
  • Cancelreply