search
  • Sign In
  • Sign Up
Password reset successful

Follow the proiects vou are interested in andi aet the latestnews about them taster

Login form submission and processing

It can be seen from the form submission

<form action="/public/index.php/index/login/login" method="post">

Continue to edit application/index/controller/Login.php and add the following code:

<?php
public function login($user_name='',$user_passwd=''){
//      var_dump($user_name);die();
   $user = User::get([
      'user_name' => $user_name,
      'user_passwd' => $user_passwd
      ]);
   if($user){
      echo '登录成功';
   }else{
        return $this->error('登录失败');
   }
  }

Login() directly passes in the parameters in When submitting to the login method of the login controller, the constructor will be called to obtain the data submitted by the form, and then the user's get method will be used to query and compare it with the database. If there is data, it will print out that the login is successful, otherwise it will jump to the original login page if the login fails;


The effect is shown below:

gif5新文件 (12).gif

new file
<?php echo "登录功能的实现";
Reset Code
Automatic operation
submit
Preview Clear