gpt4 book ai didi

laravel - 非法字符串偏移量 'name' laravel php

转载 作者:行者123 更新时间:2023-12-05 00:48:17 25 4
gpt4 key购买 nike

这是我的注册页面 View 和 Controller 。我正在使用 Laravel 框架。我已经检查过这个,它因为密码字段而出错。我在没有密码字段的情况下编译了它并且它起作用了。我无法理解其中有什么问题。我从 laravel 集体表单页面复制了它。

查看:

{!! Form::open(['url' => 'signup/submit']) !!}
<div class="form-group">
{{Form::label('name', 'Name')}}
{{Form::text('name', '', ['class' => 'form-control', 'placeholder' => 'Full Name'])}}
</div>
<div class="form-group">
{{Form::label('username', 'Username')}}
{{Form::text('username', '', ['class' => 'form-control', 'placeholder' => 'Username'])}}
</div>
<div class="form-group">
{{Form::label('email', 'E-Mail Address')}}
{{Form::email('email', '', ['class' => 'form-control', 'placeholder' => 'Your email..'])}}
</div>
<div class="form-group">
{{Form::label('password', 'Password')}}
{{Form::password('password', '123', ['class' => 'form-control', 'placeholder' => 'Password...'])}}
</div>
<div>
{{Form::submit('Submit', ['class' => 'btn btn-primary'])}}
</div>
{!! Form::close() !!}

Controller :
public function submit(Request $request)
{
$this->validate($request, [
'name' => 'required',
'username' => 'username',
'email' => 'email',
'password' => 'password'
]);

//Getting the info and creating new message.
$message = new Message;
$message->name = $request->input('name');
$message->username = $request->input('username');
$message->message = $request->input('email');
$message->message = $request->input('password');

$message->save();

//redirecting
return redirect('/')->with('success', 'Registeration successful');
}

如果有人能理解这个问题吗?

这是错误屏幕截图:
Error screenshot

最佳答案

好的,我找到了,这是因为密码字段没有显示值。

改变这个

{{Form::password('password', '123', ['class' => 'form-control', 'placeholder' => 'Password...'])}}

对此
{{Form::password('password', ['class' => 'form-control', 'placeholder' => 'Password...'])}}

来自 https://laravel.io/forum/08-12-2014-illegal-string-offset-name-when-validating-against-unique

关于laravel - 非法字符串偏移量 'name' laravel php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49902590/

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