gpt4 book ai didi

php - 显示未定义索引 : password 的错误

转载 作者:可可西里 更新时间:2023-11-01 00:56:31 26 4
gpt4 key购买 nike

我是我的 session Controller ,我为验证电子邮件、登录名和更改密码编写代码,但出现错误

ErrorException in EloquentUserProvider.php line 116: Undefined index: password.

并从行代码中获取错误

if (!Auth::attempt($credentials_verifiy))

<?php
namespace App\Http\Controllers;

use Request;
use Response;
//----models--------
use App\Site;
use App\Jobs;


use Auth;
use DB;
use Validator;
use Redirect;

//use Illuminate\Support\Facades\Validator;
use Illuminate\Support\MessageBag;
class SessionController extends Controller {

public function index(){
return Redirect::to('login')->with('alert-success', 'test awrnning message.');
}
public function store()
{
$input = Request::only('username', 'email', 'password');
$credentials = [
'username' => Request::get('username'),
'password' => Request::get('password')
];

if (!Auth::attempt($credentials))
{
return Redirect::back()->with('alert-danger', 'Username or password do not match.');
}
else
{
$credentials_verifiy = [
'verified_email' => '1'
];
if (!Auth::attempt($credentials_verifiy))
{
return Redirect::back()->with('alert-danger', 'Please verify your email.');
}
else
{
if(Auth::user()->last_login_at=='' || Auth::user()->last_login_at==null)
{
return redirect('/change_password');
}
else
{
return redirect('/tests');
}
}
}
}
}

最佳答案

为了跳过这个异常你可以使用这行代码

array_get('password', $input);

如果数组 $input 没有索引 password 它不会抛出异常,它会返回 null,你可以让它返回你想要的: array_get('密码', $input, ' ');

关于php - 显示未定义索引 : password 的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41117495/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com