404在laravel 6中找不到
问题描述:
我在将变量传递到URL时遇到问题,该路由存在,但仍未找到404, 这是表格:
i have a problem while passing a variable into the URL , the route exists but still 404 NOT FOUND , This is the form :
<form action="/rdv_{{$go->ID}}" method="post" role="form" data-aos="fade-up">
@csrf
<input placeholder="Email" type="email" class="form-control" name="email" id="email" />
<input placeholder="Votre numéro de téléphone " type="text" class="form-control" name="tel"
id="subject" />
<div id="buttons">
<button type="submit" class="btn btn-primary"> Prendre un rendez-vous </button>
</div>
</form>
这是控制器:
public function rdv ($ID) {
$nm=request('email');
$tel=request('tel');
$ID=request('{{$go->ID}}');
$doctor=doc::findOrFail($ID);
$rdv = new rendezvous() ;
$rdv->Email=$nm;
$rdv->Numéro_de_téléphone=$tel;
$rdv->IDD=$doctor->ID;
$rdv-> save();
return redirect('/index') ;
}
}
最后这是路线:
Route::post('/rdv_{ID}','rendezv@rdv');
答
我有两个发现:
首先,我可以看到您的表单操作是"/rdv _ {{$ go-> ID}}".我认为应该改为"/rdv/{{$go->ID}}"
.请注意,我将'_'更改为'/'.
First, I can see that your form action is "/rdv_{{$go->ID}}". I think it should be "/rdv/{{$go->ID}}"
instead. Note that I changed the '_' to '/'.
第二,我认为您也应该将路线更改为此(请注意,我已将'_'更改为'/'):
Second, I think you should also change your route to this (Note that I changed the '_' to '/'):
Route::post('/rdv/{ID}','rendezv@rdv');
希望能解决问题.
致谢.