404 Not found with laravel 6

半腔热情 提交于 2020-06-07 07:21:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!