laravel 表单不想发送数据
laravel form doesn't want to send data
所以我尝试使用 laravel 将此表单中的日期保存到我的数据库中,但是当我使用 print-r 测试它时
它显示表单未发送任何内容,我无法确定问题出在哪里?
查看
<form action="{{ route('auctioneer.save') }}" method="POST">
@csrf
<fieldset>
<div class="form-group" style="width: 35%; position: absolute; margin-left: 4%">
<fieldset>
<label class="control-label" for="readOnlyInput">Name</label>
<input class="form-control" id="readOnlyInput" type="text" value="{{ Auth::user()->name }}" readonly="" style="width: 100%">
</fieldset>
</div>
<div class="form-group" style="width: 35%;margin-left: 60%">
<fieldset>
<label class="control-label" for="readOnlyInput">email</label>
<input class="form-control" id="readOnlyInput" type="text" value="{{ Auth::user()->email }}" readonly="" style="width: 100%">
</fieldset>
</div>
<div class="form-group" style="width: 35%; position: absolute; margin-left: 4%">
<label for="entreprisepos">Position dans l'entreprise</label>
<input type="text" class="form-control" required id="entreprisePos" aria-describedby="aucti" placeholder="Commercial ...">
</div>
<div class="form-group" style="width: 35%;margin-left: 60%">
<label for="entrepriseNom">Nom du l'entreprise</label>
<input type="text" class="form-control" required id="entrepriseNom" aria-describedby="aucti" placeholder="Make it Happen ...">
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" id="termsChkbx " type="checkbox" value="" checked="" onchange="isChecked(this, 'sub1')">
I Agree on <a href="https://www.termsandcondiitionssample.com/"> Terms and Conditions </a>
</label>
</div>
<div class="form-group text-center">
<button type="submit" class="ps-btn" id="sub1" style="width: 20%;" value="Submit">
Submit Form
</button>
</div>
</fieldset>
</form>
路线
Route::post('/submitauct','AuctioneerController@save')->name('auctioneer.save');
控制器
public function save( Request $req){
print_r($req->input());
}
显示
数组([_token] => xNY3q1BvlxuT3zylwhtONx0Xv13qVPUhrrga8omo)
如果你想从HTML表单发送数据,你需要使用输入属性名称。
<input name="foo" value="bar">
然后就可以得到Laravel中的值了:
request()->input('foo');
你错过了标签中的名称属性你的数据是在请求中传递的,但没有得到任何名称所以你没有看到数据
当你使用像 js/jquery/css 这样的前端时,总是记住 id 是有用的,但是当你想在后端工作时,你必须传递 name 属性。
下一个错误是在 laravel 中提交表单时总是使用 not 按钮。
当您想使用 ajax 或 axios 提交表单时使用按钮很好。
提示:在 dd() 中打印令牌,因为当您使用 @csrf 时,您会得到它。
它有默认名称 属性 所以它显示
如果对您有帮助请投上一票................................................ ......
所以我尝试使用 laravel 将此表单中的日期保存到我的数据库中,但是当我使用 print-r 测试它时 它显示表单未发送任何内容,我无法确定问题出在哪里?
查看
<form action="{{ route('auctioneer.save') }}" method="POST">
@csrf
<fieldset>
<div class="form-group" style="width: 35%; position: absolute; margin-left: 4%">
<fieldset>
<label class="control-label" for="readOnlyInput">Name</label>
<input class="form-control" id="readOnlyInput" type="text" value="{{ Auth::user()->name }}" readonly="" style="width: 100%">
</fieldset>
</div>
<div class="form-group" style="width: 35%;margin-left: 60%">
<fieldset>
<label class="control-label" for="readOnlyInput">email</label>
<input class="form-control" id="readOnlyInput" type="text" value="{{ Auth::user()->email }}" readonly="" style="width: 100%">
</fieldset>
</div>
<div class="form-group" style="width: 35%; position: absolute; margin-left: 4%">
<label for="entreprisepos">Position dans l'entreprise</label>
<input type="text" class="form-control" required id="entreprisePos" aria-describedby="aucti" placeholder="Commercial ...">
</div>
<div class="form-group" style="width: 35%;margin-left: 60%">
<label for="entrepriseNom">Nom du l'entreprise</label>
<input type="text" class="form-control" required id="entrepriseNom" aria-describedby="aucti" placeholder="Make it Happen ...">
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" id="termsChkbx " type="checkbox" value="" checked="" onchange="isChecked(this, 'sub1')">
I Agree on <a href="https://www.termsandcondiitionssample.com/"> Terms and Conditions </a>
</label>
</div>
<div class="form-group text-center">
<button type="submit" class="ps-btn" id="sub1" style="width: 20%;" value="Submit">
Submit Form
</button>
</div>
</fieldset>
</form>
路线
Route::post('/submitauct','AuctioneerController@save')->name('auctioneer.save');
控制器
public function save( Request $req){
print_r($req->input());
}
显示
数组([_token] => xNY3q1BvlxuT3zylwhtONx0Xv13qVPUhrrga8omo)
如果你想从HTML表单发送数据,你需要使用输入属性名称。
<input name="foo" value="bar">
然后就可以得到Laravel中的值了:
request()->input('foo');
你错过了标签中的名称属性你的数据是在请求中传递的,但没有得到任何名称所以你没有看到数据 当你使用像 js/jquery/css 这样的前端时,总是记住 id 是有用的,但是当你想在后端工作时,你必须传递 name 属性。
下一个错误是在 laravel 中提交表单时总是使用 not 按钮。 当您想使用 ajax 或 axios 提交表单时使用按钮很好。
提示:在 dd() 中打印令牌,因为当您使用 @csrf 时,您会得到它。 它有默认名称 属性 所以它显示
如果对您有帮助请投上一票................................................ ......