在 laravel 中执行登录操作时如何解决下面提到的错误
How to solve the below mentioned error while performing login action in laravel
在下面找到控制器代码:
class SigninController extends Controller
{
protected function signin(){
$login = Whmcs::validatelogin(array(
'email' => Input::get('email'),
'password2' => Input::get('password2'),
));
if($login->result == 'success') {
echo 'User Logged In';
} elseif($login->result == 'error') {
echo $login->message;
}
}
}
路由代码如下:
Route::post('signin','SigninController@signin')->name('login.signin');
blade 文件中的表单操作如下:
<form class="bs-example form-horizontal" action="{{route('login.signin')}}" method="post">
<input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
<div class="form-group">
<label class="col-lg-2 control-label">Email</label>
<div class="col-lg-6">
<input type="email" class="form-control" name="email" placeholder="Email">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">password</label>
<div class="col-lg-6">
<input type="password" class="form-control" name="password2" placeholder="password">
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-sm btn-success">Submit</button>
</div>
</div>
</form>
在执行上面的代码时,我收到一个错误
Trying to get property 'result' of non-object. Suggest me solution to solve this while performing login action.
尝试使用
回显变量 $login
dd($login);
很可能 validatelogin 函数的输出不是一个对象。
在下面找到控制器代码:
class SigninController extends Controller
{
protected function signin(){
$login = Whmcs::validatelogin(array(
'email' => Input::get('email'),
'password2' => Input::get('password2'),
));
if($login->result == 'success') {
echo 'User Logged In';
} elseif($login->result == 'error') {
echo $login->message;
}
}
}
路由代码如下:
Route::post('signin','SigninController@signin')->name('login.signin');
blade 文件中的表单操作如下:
<form class="bs-example form-horizontal" action="{{route('login.signin')}}" method="post">
<input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
<div class="form-group">
<label class="col-lg-2 control-label">Email</label>
<div class="col-lg-6">
<input type="email" class="form-control" name="email" placeholder="Email">
</div>
</div>
<div class="form-group">
<label class="col-lg-2 control-label">password</label>
<div class="col-lg-6">
<input type="password" class="form-control" name="password2" placeholder="password">
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-sm btn-success">Submit</button>
</div>
</div>
</form>
在执行上面的代码时,我收到一个错误
Trying to get property 'result' of non-object. Suggest me solution to solve this while performing login action.
尝试使用
回显变量 $logindd($login);
很可能 validatelogin 函数的输出不是一个对象。