问题
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>
And this is the controller :
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') ;
}
}
and finally this is the route :
Route::post('/rdv_{ID}','rendezv@rdv');
回答1:
I have two observations:
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');
Hope that solves the problem.
Regards.
来源:https://stackoverflow.com/questions/61841553/404-not-found-with-laravel-6